aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
+
}
}