Fix dive trip merging logic

Linus Torvalds torvalds at
Fri Nov 9 10:46:39 PST 2012

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 updates
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 at>

I really do think we should also re-write the trip logic to not use
those GList things, and this changes "delete_trip()" to be such a
non-GList interface. If we do enough of those kinds of details, maybe
we can then change the data structures to be more about just list of
dives and the associated dive trips, and not so tied into the
divelist.c logic and the gtk list handling.

We'll see when I get to that, but in the meantime this seems to work
at least for my one test-case of multi-computer usage.

There are *other* issues that mean that merging dives (the dive
samples in particular) from different computers doesn't work really
all that well. It *happens* to work for the Suunto Vyper Air vs the
Suunto HelO2, at least when they have the same sample rate etc, but
I'll need to re-do the sample merging entirely. But that's a separate
issue from the dive trip handling.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 7760 bytes
Desc: not available
URL: <>

More information about the subsurface mailing list