summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-11-09 19:46:39 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-09 21:46:56 +0100
commit7f515eb7e53c5ab6d8dde4d2e6876464ed7fdeae (patch)
treef92ba6756103c85a431f18d9333c26374ce29ceb /main.c
parent51003eaed71ea823dc8ce88e7de0e785a50b24cb (diff)
downloadsubsurface-7f515eb7e53c5ab6d8dde4d2e6876464ed7fdeae.tar.gz
Fix dive trip merging logic
We used to have very spotty logic for picking the dive trip when merging two dives. It turns out that that spotty logic almost never really matters, because in practice you'll never hit the situation of merging two dives with different dive trips, but it *can* happen. In particular, it happens when you use multiple dive computers, and end up loading the dives from one computer on top of the dives of your other computer. If the clocks of the dive computers was set sufficiently close to each other, the dive merging logic will kick in and you may now have slightly different times for the dives that get merged, and the trip merging logic got *really* confused. The trip management also depends on the trip dates being updated correctly when the dives associated with a trip are updated (whether added or removed), and the trip merging code did none of that. This fixes it all up. Hopefully correctly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main.c b/main.c
index ca3722383..ff874834c 100644
--- a/main.c
+++ b/main.c
@@ -126,12 +126,16 @@ void report_dives(gboolean is_imported)
struct dive **pp = &dive_table.dives[i-1];
struct dive *prev = pp[0];
struct dive *dive = pp[1];
+ struct dive *next;
struct dive *merged;
if (prev->when + prev->duration.seconds < dive->when)
continue;
- merged = try_to_merge(prev, dive);
+ next = NULL;
+ if (i < dive_table.nr-1)
+ next = pp[2];
+ merged = try_to_merge(prev, dive, next);
if (!merged)
continue;