mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove event: don't compare pointers, compare events
This used to work because we actually displayed the current_dive. Now with displayed_dive the pointers are of course different! So we need to compare the actual events instead. See #616 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7bbe71ff33
commit
f9b18b9bfb
1 changed files with 14 additions and 14 deletions
28
dive.c
28
dive.c
|
@ -51,10 +51,23 @@ void add_event(struct divecomputer *dc, int time, int type, int flags, int value
|
||||||
remember_event(name);
|
remember_event(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int same_event(struct event *a, struct event *b)
|
||||||
|
{
|
||||||
|
if (a->time.seconds != b->time.seconds)
|
||||||
|
return 0;
|
||||||
|
if (a->type != b->type)
|
||||||
|
return 0;
|
||||||
|
if (a->flags != b->flags)
|
||||||
|
return 0;
|
||||||
|
if (a->value != b->value)
|
||||||
|
return 0;
|
||||||
|
return !strcmp(a->name, b->name);
|
||||||
|
}
|
||||||
|
|
||||||
void remove_event(struct event* event)
|
void remove_event(struct event* event)
|
||||||
{
|
{
|
||||||
struct event **ep = ¤t_dc->events;
|
struct event **ep = ¤t_dc->events;
|
||||||
while (ep && *ep != event)
|
while (ep && !same_event(*ep, event))
|
||||||
ep = &(*ep)->next;
|
ep = &(*ep)->next;
|
||||||
if (ep) {
|
if (ep) {
|
||||||
*ep = event->next;
|
*ep = event->next;
|
||||||
|
@ -1886,19 +1899,6 @@ static void free_pic(struct picture *picture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int same_event(struct event *a, struct event *b)
|
|
||||||
{
|
|
||||||
if (a->time.seconds != b->time.seconds)
|
|
||||||
return 0;
|
|
||||||
if (a->type != b->type)
|
|
||||||
return 0;
|
|
||||||
if (a->flags != b->flags)
|
|
||||||
return 0;
|
|
||||||
if (a->value != b->value)
|
|
||||||
return 0;
|
|
||||||
return !strcmp(a->name, b->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int same_sample(struct sample *a, struct sample *b)
|
static int same_sample(struct sample *a, struct sample *b)
|
||||||
{
|
{
|
||||||
if (a->time.seconds != b->time.seconds)
|
if (a->time.seconds != b->time.seconds)
|
||||||
|
|
Loading…
Add table
Reference in a new issue