When deleting a cylinder, adapt gas changes

When we delete a cylinder the gas changes in that dive may have to be
adjusted. We didn't do this at all in the past. With this commit we should
be doing this right for a single dive that is being edited.

This does NOT handle multiple dives being edited at the same time (or more
specifically - if you have multiple dives selected and delete a cylinder,
the dives that had the same set of cylinders (other than the displayed
dive) will get that particular cylinder deleted, but won't have their gas
change events (and sensor data in the samples) adapted.

Possibly we should simply prohibit deleting cylinders when more than one
dive are selected.

See #834

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-04-23 15:24:02 -07:00
parent bbfa2b655b
commit 415abeea66
4 changed files with 29 additions and 2 deletions

4
dive.c
View file

@ -1758,7 +1758,7 @@ static void add_initial_gaschange(struct dive *dive, struct divecomputer *dc)
add_gas_switch_event(dive, dc, 0, 0);
}
static void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, int mapping[])
void dc_cylinder_renumber(struct dive *dive, struct divecomputer *dc, int mapping[])
{
int i;
struct event *ev;
@ -2259,7 +2259,7 @@ struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded
return NULL;
}
static void free_events(struct event *ev)
void free_events(struct event *ev)
{
while (ev) {
struct event *next = ev->next;