diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-11 14:46:05 +0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-11 16:46:21 +0700 |
commit | 9fca37acecdc0e8a622f7618b205383348611dac (patch) | |
tree | f792e1cf34149dbdc613e07dbf47f8e78c2cd0c0 /dive.c | |
parent | a8c0bf3e572dbdf4d3943edead5739138a68432b (diff) | |
download | subsurface-9fca37acecdc0e8a622f7618b205383348611dac.tar.gz |
Properly handle user dive merge requests
When the user asks to merge dives in the divelist, we would always use
the "try tp find matching dive computers and merge at an offset" model.
That is incorrect if the intent is to actually merge two *identical*
dives (with different dive computers), as opposed to merging two short
dives into one longer one with a surface interval.
Normally this doesn't ever trigger (the "same dive" merging will have
been done automatically after downloading from the dive computer), but
if the dive computer times are off, and the user fixes them, and then
asks to merge dives, we should use the non-offset dive merging logic.
We already have that "likely_same_dive()" function that is used to
determine when downloaded dives get merged, so just use it for the user
merge case too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -2064,6 +2064,14 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer if (prefer_downloaded && b->downloaded) dl = b; + /* + * Did the user ask us to merge dives in the dive list? + * We may want to just join the dive computers, not try to + * interleave them at some offset. + */ + if (offset && likely_same_dive(a, b)) + offset = 0; + res->when = dl ? dl->when : a->when; res->selected = a->selected || b->selected; merge_trip(res, a, b); |