diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-09 19:46:39 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-09 21:46:56 +0100 |
commit | 7f515eb7e53c5ab6d8dde4d2e6876464ed7fdeae (patch) | |
tree | f92ba6756103c85a431f18d9333c26374ce29ceb /dive.h | |
parent | 51003eaed71ea823dc8ce88e7de0e785a50b24cb (diff) | |
download | subsurface-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 'dive.h')
-rw-r--r-- | dive.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -242,7 +242,7 @@ struct event { #define W_IDX_SECONDARY 1 typedef gint64 timestamp_t; -typedef enum { TF_NONE, NO_TRIP, IN_TRIP, ASSIGNED_TRIP, AUTOGEN_TRIP, NUM_TRIPFLAGS } tripflag_t; +typedef enum { TF_NONE, NO_TRIP, IN_TRIP, AUTOGEN_TRIP, ASSIGNED_TRIP, NUM_TRIPFLAGS } tripflag_t; extern const char *tripflag_names[NUM_TRIPFLAGS]; typedef struct dive_trip { @@ -298,6 +298,7 @@ extern gboolean autogroup; #define DIVE_FITS_TRIP(_dive, _dive_trip) ((_dive_trip)->when - TRIP_THRESHOLD <= (_dive)->when) extern void insert_trip(dive_trip_t **trip); +extern void delete_trip(dive_trip_t *trip); /* * We keep our internal data in well-specified units, but @@ -390,7 +391,7 @@ extern void finish_sample(struct dive *dive); extern void report_dives(gboolean imported); extern struct dive *fixup_dive(struct dive *dive); -extern struct dive *try_to_merge(struct dive *a, struct dive *b); +extern struct dive *try_to_merge(struct dive *a, struct dive *b, struct dive *next); extern void renumber_dives(int nr); |