diff options
author | Robert C. Helling <helling@atdotde.de> | 2020-08-17 22:04:53 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-08-24 08:30:00 -0700 |
commit | 62d87e9d25763e81757de417640f464e2bf5a2c0 (patch) | |
tree | 47ad686f6b44f5429340fe47e33198bfc5ed18b6 | |
parent | c5b1fd9f5336a8bb4ae048f6f31ac3e3651a5ea3 (diff) | |
download | subsurface-62d87e9d25763e81757de417640f464e2bf5a2c0.tar.gz |
Planner: handle zero length segments when replanning
When setting up a dive for replanning, we ignored zero length segments as those
tend to be generated by gas changes. But it is possible to enter those in the
planner and the replanning should not ignore those. So be
more clever about gas changes. Let's add 10 seconds so we are not at two depths
at the same time and help since add_stop also does not like zero length
segments (it thinks we are trying to replace a waypoint).
Fixes #2901
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
m--------- | libdivecomputer | 0 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 7 |
3 files changed, 7 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4971abc3f..18240f402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ core: add support for Shearwater Peregrine (requires firmware V79 or newer) core: fix renumbering of imported dives [#2731] mobile: fix editing tank information +planner: Handle zero length segments gracefully when replanning mobile: disable download button if no connection is selected mobile: fix incorrect time stamps on GPS track points created via location service core: correctly recognize A1 as BLE dive computer diff --git a/libdivecomputer b/libdivecomputer -Subproject ad566ab04f6ef3943d2306b41b35ac427afddb4 +Subproject 1df0e13cc44041743836065c66928c06a5c035a diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index ebcbeb51e..bdc79c9e6 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -128,6 +128,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) int plansamples = dc->samples <= 100 ? dc->samples : 100; int j = 0; int cylinderid = 0; + last_sp.mbar = 0; for (int i = 0; i < plansamples - 1; i++) { if (dc->last_manual_time.seconds && dc->last_manual_time.seconds > 120 && lasttime.seconds >= dc->last_manual_time.seconds) @@ -145,7 +146,11 @@ void DivePlannerPointsModel::loadFromDive(dive *d) } if (samplecount) { cylinderid = get_cylinderid_at_time(d, dc, lasttime); - if (newtime.seconds - lastrecordedtime.seconds > 10) { + duration_t nexttime = newtime; + ++nexttime.seconds; + if (newtime.seconds - lastrecordedtime.seconds > 10 || cylinderid == get_cylinderid_at_time(d, dc, nexttime)) { + if (newtime.seconds == lastrecordedtime.seconds) + newtime.seconds += 10; current_divemode = get_current_divemode(dc, newtime.seconds - 1, &evd, ¤t_divemode); addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true, current_divemode); lastrecordedtime = newtime; |