From 7821b879837cae62a5e9e8ecf1071656852eb371 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 20 May 2014 14:01:40 +0900 Subject: Use the last 'diveid' when merging dives for one dive computer When we merge two dives into the same dive because a divecomputer had incorrectly considered it two separate dives (due to surface time within the dive) we should pick the dive ID from the later dive to be the diveid of the resulting merged dive. Otherwise we might re-download the (now merged) partial dive. This is a rather unusual special case, but it actually hit me with the Uemis on my last dive in Palau: Chandelier Cave has multiple surface points where you can spend time admiring the cave above water, and the Uemis (but not my Suunto's) decided that the dive was actually four short dives back-to-back. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- dive.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dive.c b/dive.c index cc673f122..d9943c23f 100644 --- a/dive.c +++ b/dive.c @@ -1926,6 +1926,9 @@ static void interleave_dive_computers(struct divecomputer *res, if (match) { merge_events(res, a, match, offset); merge_samples(res, a, match, offset); + /* Use the diveid of the later dive! */ + if (offset > 0) + res->diveid = match->diveid; } else { res->sample = a->sample; res->samples = a->samples; -- cgit v1.2.3-70-g09d2