summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-12 12:21:05 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-12 12:21:05 -0700
commitf9b18b9bfbdd3ef89750cd9b231d57df550db28b (patch)
tree791c9c661773bf4815e5ddeaed642cc6a0c9d6ec /dive.c
parent7bbe71ff3399334e617d4e07e321336c03ddc9ab (diff)
downloadsubsurface-f9b18b9bfbdd3ef89750cd9b231d57df550db28b.tar.gz
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>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/dive.c b/dive.c
index 4cb9672ed..1dd943e48 100644
--- a/dive.c
+++ b/dive.c
@@ -51,10 +51,23 @@ void add_event(struct divecomputer *dc, int time, int type, int flags, int value
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)
{
struct event **ep = &current_dc->events;
- while (ep && *ep != event)
+ while (ep && !same_event(*ep, event))
ep = &(*ep)->next;
if (ep) {
*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)
{
if (a->time.seconds != b->time.seconds)