diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-02-25 20:51:13 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-04 12:16:49 -0800 |
commit | f1c46927effcc2182fff3f7acf507ba68cad8ade (patch) | |
tree | b479f8cc6062ddca0f3d87f6cc318a58fc3e3538 /qt-models | |
parent | b60b7c108e27ed60d19932425e82db3eecbd4fde (diff) | |
download | subsurface-f1c46927effcc2182fff3f7acf507ba68cad8ade.tar.gz |
Ensure correct length of the created dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index fc7e479eb..4151e0c39 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -94,6 +94,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) // average samples so we end up with a total of 100 samples. int plansamples = dc->samples <= 100 ? dc->samples : 100; int j = 0; + int cylinderid; for (int i = 0; i < plansamples - 1; i++) { while (j * plansamples <= i * dc->samples) { const sample &s = dc->sample[j]; @@ -105,7 +106,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d) j++; } if (samplecount) { - int cylinderid = get_cylinderid_at_time(d, dc, lasttime); + cylinderid = get_cylinderid_at_time(d, dc, lasttime); if (newtime.seconds - lastrecordedtime.seconds > 10) { addStop(depthsum / samplecount, newtime.seconds, cylinderid, 0, true); lastrecordedtime = newtime; @@ -115,6 +116,8 @@ void DivePlannerPointsModel::loadFromDive(dive *d) samplecount = 0; } } + // make sure we get the last point right so the duration is correct + addStop(0, d->dc.duration.seconds,cylinderid, 0, true); recalc = oldRec; emitDataChanged(); } |