diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-22 12:32:27 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-22 19:36:54 -0700 |
commit | 34da4801f45c6fb06d3a7b55029fc4ebd702a6e6 (patch) | |
tree | 9272adb2fc49e91d2dad4fc37f1c1a71c68e2a48 /qt-ui/divelistview.cpp | |
parent | 000a93fb64d92729c51762e1483d36859d442e9d (diff) | |
download | subsurface-34da4801f45c6fb06d3a7b55029fc4ebd702a6e6.tar.gz |
Be much more careful about merging dives
This patch changes the dive merging to be much more careful about
things, because it turns out that we had several small oddities that
caused big merge issues.
The oddities are:
- the dive "duration" is actually how long we spend under water.
But that means that when we do "dive->when + dive.duration.seconds"
to calculate the end of the dive, that is nonsensical if you came up
to the surface in the middle of a dive.
Now, normally you don't see profiles like that, but once you start
merging dives together, it can go from "small detail" to "dominant
factor".
- We have two different cases of merging: the automatic "merge new dive
computer download if it looks like the same dive" (which always has a
merge offset of 0, since we merge it as a new dive computer) and the
"merge two different dives into one longer dive.
The code assumed that it could look at the "downloaded" flag for the
dive to check one or the other, but that doesn't really work.
Reading a dive from an XML file isn't any different from downloading
it.
So we need to change the logic to determine what kind of merge it is
to actually check the passed-in time offset.
With this, Stuart Vernon's test-case of eight dives with short surface
intervals in between end up merging correctly into one dive.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Stuart Vernon <stuartv@force2.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 2ee5f5dcd..39eab9c7a 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -22,6 +22,7 @@ #include "divelistview.h" #include "divepicturemodel.h" #include "metrics.h" +#include "helpers.h" // # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Loc static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 500}; @@ -575,12 +576,12 @@ static bool can_merge(const struct dive *a, const struct dive *b, enum asked_use if (a->when > b->when) return false; /* Don't merge dives if there's more than half an hour between them */ - if (a->when + a->duration.seconds + 30 * 60 < b->when) { + if (dive_endtime(a) + 30 * 60 < b->when) { if (*have_asked == NOTYET) { if (QMessageBox::warning(MainWindow::instance(), MainWindow::instance()->tr("Warning"), MainWindow::instance()->tr("Trying to merge dives with %1min interval in between").arg( - (b->when - a->when - a->duration.seconds) / 60), + (b->when - dive_endtime(a)) / 60), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) { *have_asked = DONTMERGE; return false; |