mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Correctly copy all information in an event
Instead of trying to use add_event() to reinsert events we simply copy the memory and adjust the pointers. Using add_event() lost the gas mix and gas index information on gaschange events - and this prevent switches between cylinders with the same gasmix to be rendered correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
49c9ad199f
commit
613402f6c9
1 changed files with 9 additions and 4 deletions
13
dive.c
13
dive.c
|
@ -491,18 +491,23 @@ void selective_copy_dive(struct dive *s, struct dive *d, struct dive_components
|
|||
}
|
||||
#undef CONDITIONAL_COPY_STRING
|
||||
|
||||
/* only copies events from the first dive computer */
|
||||
/* copies all events in this dive computer */
|
||||
void copy_events(struct divecomputer *s, struct divecomputer *d)
|
||||
{
|
||||
struct event *ev;
|
||||
struct event *ev, **pev;
|
||||
if (!s || !d)
|
||||
return;
|
||||
ev = s->events;
|
||||
d->events = NULL;
|
||||
pev = &d->events;
|
||||
while (ev != NULL) {
|
||||
add_event(d, ev->time.seconds, ev->type, ev->flags, ev->value, ev->name);
|
||||
int size = sizeof(*ev) + strlen(ev->name) + 1;
|
||||
struct event *new_ev = malloc(size);
|
||||
memcpy(new_ev, ev, size);
|
||||
*pev = new_ev;
|
||||
pev = &new_ev->next;
|
||||
ev = ev->next;
|
||||
}
|
||||
*pev = NULL;
|
||||
}
|
||||
|
||||
int nr_cylinders(struct dive *dive)
|
||||
|
|
Loading…
Add table
Reference in a new issue