mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
51003eaed7
commit
7f515eb7e5
4 changed files with 106 additions and 19 deletions
6
main.c
6
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue