mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d541b9fd42
commit
719b732230
3 changed files with 10 additions and 7 deletions
11
divelist.c
11
divelist.c
|
@ -615,7 +615,7 @@ void find_new_trip_start_time(dive_trip_t *trip)
|
||||||
trip->when = when;
|
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;
|
struct dive *next, **pprev;
|
||||||
dive_trip_t *trip = dive->divetrip;
|
dive_trip_t *trip = dive->divetrip;
|
||||||
|
@ -631,6 +631,9 @@ void remove_dive_from_trip(struct dive *dive)
|
||||||
next->pprev = pprev;
|
next->pprev = pprev;
|
||||||
|
|
||||||
dive->divetrip = NULL;
|
dive->divetrip = NULL;
|
||||||
|
if (was_autogen)
|
||||||
|
dive->tripflag = TF_NONE;
|
||||||
|
else
|
||||||
dive->tripflag = NO_TRIP;
|
dive->tripflag = NO_TRIP;
|
||||||
assert(trip->nrdives > 0);
|
assert(trip->nrdives > 0);
|
||||||
if (!--trip->nrdives)
|
if (!--trip->nrdives)
|
||||||
|
@ -644,7 +647,7 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip)
|
||||||
if (dive->divetrip == trip)
|
if (dive->divetrip == trip)
|
||||||
return;
|
return;
|
||||||
assert(trip->when);
|
assert(trip->when);
|
||||||
remove_dive_from_trip(dive);
|
remove_dive_from_trip(dive, FALSE);
|
||||||
trip->nrdives++;
|
trip->nrdives++;
|
||||||
dive->divetrip = trip;
|
dive->divetrip = trip;
|
||||||
dive->tripflag = ASSIGNED_TRIP;
|
dive->tripflag = ASSIGNED_TRIP;
|
||||||
|
@ -722,7 +725,7 @@ void delete_single_dive(int idx)
|
||||||
struct dive *dive = get_dive(idx);
|
struct dive *dive = get_dive(idx);
|
||||||
if (!dive)
|
if (!dive)
|
||||||
return; /* this should never happen */
|
return; /* this should never happen */
|
||||||
remove_dive_from_trip(dive);
|
remove_dive_from_trip(dive, FALSE);
|
||||||
if (dive->selected)
|
if (dive->selected)
|
||||||
deselect_dive(idx);
|
deselect_dive(idx);
|
||||||
for (i = idx; i < dive_table.nr - 1; i++)
|
for (i = idx; i < dive_table.nr - 1; i++)
|
||||||
|
@ -863,7 +866,7 @@ void remove_autogen_trips()
|
||||||
dive_trip_t *trip = dive->divetrip;
|
dive_trip_t *trip = dive->divetrip;
|
||||||
|
|
||||||
if (trip && trip->autogen)
|
if (trip && trip->autogen)
|
||||||
remove_dive_from_trip(dive);
|
remove_dive_from_trip(dive, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ extern int trip_has_selected_dives(dive_trip_t *trip);
|
||||||
extern void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p);
|
extern void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p);
|
||||||
extern int get_divenr(struct dive *dive);
|
extern int get_divenr(struct dive *dive);
|
||||||
extern dive_trip_t *find_matching_trip(timestamp_t when);
|
extern dive_trip_t *find_matching_trip(timestamp_t when);
|
||||||
extern void remove_dive_from_trip(struct dive *dive);
|
extern void remove_dive_from_trip(struct dive *dive, short was_autogen);
|
||||||
extern dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive);
|
extern dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive);
|
||||||
extern void autogroup_dives(void);
|
extern void autogroup_dives(void);
|
||||||
extern struct dive *merge_two_dives(struct dive *a, struct dive *b);
|
extern struct dive *merge_two_dives(struct dive *a, struct dive *b);
|
||||||
|
|
|
@ -548,7 +548,7 @@ void DiveListView::removeFromTrip()
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
for_each_dive(i, d) {
|
for_each_dive(i, d) {
|
||||||
if (d->selected)
|
if (d->selected)
|
||||||
remove_dive_from_trip(d);
|
remove_dive_from_trip(d, FALSE);
|
||||||
}
|
}
|
||||||
rememberSelection();
|
rememberSelection();
|
||||||
reload(currentLayout, false);
|
reload(currentLayout, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue