diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-12-12 15:03:25 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-12 15:03:25 -0800 |
commit | 719b732230ea7a7afc28944ae359f762d6a6ef48 (patch) | |
tree | ba91bfdf2e3a94cfb268bb0b0a3cfdf456c42053 /divelist.c | |
parent | d541b9fd421caa410c5e186b26b82cd238b6447b (diff) | |
download | subsurface-719b732230ea7a7afc28944ae359f762d6a6ef48.tar.gz |
Fix incorrect handling of autogrouped trips
When toggling autogroup in the menu we ended up setting the NO_TRIP flag
for dives that were removed from a trip that was created by autogroup. So
toggling things on and off and on again meant no more auto grouping.
Fixes #337
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/divelist.c b/divelist.c index 0004832c6..eacf23b3d 100644 --- a/divelist.c +++ b/divelist.c @@ -615,7 +615,7 @@ void find_new_trip_start_time(dive_trip_t *trip) trip->when = when; } -void remove_dive_from_trip(struct dive *dive) +void remove_dive_from_trip(struct dive *dive, short was_autogen) { struct dive *next, **pprev; dive_trip_t *trip = dive->divetrip; @@ -631,7 +631,10 @@ void remove_dive_from_trip(struct dive *dive) next->pprev = pprev; dive->divetrip = NULL; - dive->tripflag = NO_TRIP; + if (was_autogen) + dive->tripflag = TF_NONE; + else + dive->tripflag = NO_TRIP; assert(trip->nrdives > 0); if (!--trip->nrdives) delete_trip(trip); @@ -644,7 +647,7 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip) if (dive->divetrip == trip) return; assert(trip->when); - remove_dive_from_trip(dive); + remove_dive_from_trip(dive, FALSE); trip->nrdives++; dive->divetrip = trip; dive->tripflag = ASSIGNED_TRIP; @@ -722,7 +725,7 @@ void delete_single_dive(int idx) struct dive *dive = get_dive(idx); if (!dive) return; /* this should never happen */ - remove_dive_from_trip(dive); + remove_dive_from_trip(dive, FALSE); if (dive->selected) deselect_dive(idx); for (i = idx; i < dive_table.nr - 1; i++) @@ -863,7 +866,7 @@ void remove_autogen_trips() dive_trip_t *trip = dive->divetrip; if (trip && trip->autogen) - remove_dive_from_trip(dive); + remove_dive_from_trip(dive, TRUE); } } |