From b0da8c2707366234a6971cbfbfd4475e8cb90c0e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sat, 5 Jul 2014 13:54:08 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 19 +++++++------------ 1 file 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 + } } -- cgit v1.2.3-70-g09d2