diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-06 13:04:37 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-06 13:04:37 -0800 |
commit | 936d289cb7d5c1af9aa47784557bbf053cdbb988 (patch) | |
tree | de9aaf585bd9da5accaef8403e5a245366cd4723 | |
parent | 5ac5408bb0775b7126242ec614b48b14cbdf3ab9 (diff) | |
download | subsurface-936d289cb7d5c1af9aa47784557bbf053cdbb988.tar.gz |
Fix insert_trip to correctly deal with trips that start at the same time
The existing code did not move the dives that are part of the second trip
to the first trip (and forgot to keep the 'better' notes as well).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | divelist.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/divelist.c b/divelist.c index 128ee0c99..7a2f4fa5b 100644 --- a/divelist.c +++ b/divelist.c @@ -1008,6 +1008,7 @@ void insert_trip(dive_trip_t **dive_trip_p) dive_trip_t *dive_trip = *dive_trip_p; dive_trip_t **p = &dive_trip_list; dive_trip_t *trip; + struct dive *divep; /* Walk the dive trip list looking for the right location.. */ while ((trip = *p) != NULL && trip->when < dive_trip->when) @@ -1016,6 +1017,13 @@ void insert_trip(dive_trip_t **dive_trip_p) if (trip && trip->when == dive_trip->when) { if (! trip->location) trip->location = dive_trip->location; + if (! trip->notes) + trip->notes = dive_trip->notes; + divep = dive_trip->dives; + while (divep) { + add_dive_to_trip(divep, trip); + divep = divep->next; + } *dive_trip_p = trip; } else { dive_trip->next = trip; @@ -1829,6 +1837,7 @@ void merge_trips_cb(GtkWidget *menuitem, GtkTreePath *trippath) prevtrip = find_matching_trip(when); remember_tree_state(); /* move dives from trip */ + assert(thistrip != prevtrip); while (thistrip->dives) add_dive_to_trip(thistrip->dives, prevtrip); dive_list_update_dives(); |