[PATCH] Properly handle user dive merge requests
Linus Torvalds
torvalds at linux-foundation.org
Sat Jan 11 00:07:41 UTC 2014
From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sat, 11 Jan 2014 14:46:05 +0700
Subject: [PATCH] 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 at linux-foundation.org>
---
This fixes the workflow I tried after screwing up the time on two of my
dive computers, while having one dive computer with correct time. Now it
does the right thing when you fix the time offset and then ask subsurface
to merge the dives.
dive.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dive.c b/dive.c
index a902bca68167..5a10af5954ac 100644
--- a/dive.c
+++ b/dive.c
@@ -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);
--
1.8.4.2
More information about the subsurface
mailing list