aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-07-05 13:54:08 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-05 07:43:41 -0700
commitb0da8c2707366234a6971cbfbfd4475e8cb90c0e (patch)
treeb557e533d573b2800465053ebe776663ac9d3842
parent79cd5ce83517749f221304ddf518f39c5d6d3532 (diff)
downloadsubsurface-b0da8c2707366234a6971cbfbfd4475e8cb90c0e.tar.gz
When adding a waypoint, use the gasmix of the _next_ waypoint.
This corrects the logic of adding a waypoint actually meaning that a previous segment is subdivided into two. Both new segments should by default use the gas of the old one. Since the gas is stored in the waypoint (divedatapoint) at the end, we need to use the _next_ gas. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/diveplanner.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 0bc9a1271..15cdc5409 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -833,20 +833,15 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, gasmix *gas_in,
break;
}
}
+ // Previous, actually means next as we are typically subdiving a segment and the gas for
+ // the segment is determined by the waypoint at the end.
if (usePrevious) {
- if (row > 0) {
- gas = divepoints.at(row - 1).gasmix;
+ if (row < divepoints.count()) {
+ gas = divepoints.at(row).gasmix;
} else {
- // when we add a first data point we need to make sure that there is a
- // tank for it to use;
- // first check to the right, then to the left, but if there's nothing,
- // we simply default to AIR
- if (row < divepoints.count()) {
- gas = divepoints.at(row).gasmix;
- } else {
- if (!addGas(air))
- qDebug("addGas failed"); // FIXME add error propagation
- }
+ if (!addGas(air))
+ qDebug("addGas failed"); // FIXME add error propagation
+
}
}