From 4128fec1ea2d2c7f1127611af5afcd90ad052f27 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 12 Feb 2023 16:18:17 +0100 Subject: [PATCH] profile: register event names on creation of events The event names were registered in add_event(). However, the undo system did not use that function, but add_event_to_dc(), which takes an already allocated event. That gave the following unfortunate situation: Load a log without setpoint changes. Add a setpoint change. The setpoint change event type now was not registered and therefore couldn't be hidden. Admittedly, a subtle bug, but still a bug. Fix by registering event names on event creation. Signed-off-by: Berthold Stoeger --- core/divecomputer.c | 2 -- core/event.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/divecomputer.c b/core/divecomputer.c index e7c5e783a..cb3f43937 100644 --- a/core/divecomputer.c +++ b/core/divecomputer.c @@ -2,7 +2,6 @@ #include "divecomputer.h" #include "event.h" -#include "eventname.h" #include "extradata.h" #include "pref.h" #include "sample.h" @@ -443,7 +442,6 @@ struct event *add_event(struct divecomputer *dc, unsigned int time, int type, in add_event_to_dc(dc, ev); - remember_event_name(name); return ev; } diff --git a/core/event.c b/core/event.c index fe38bbebb..defdffc34 100644 --- a/core/event.c +++ b/core/event.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "event.h" +#include "eventname.h" #include "subsurface-string.h" #include @@ -79,6 +80,8 @@ struct event *create_event(unsigned int time, int type, int flags, int value, co break; } + remember_event_name(name); + return ev; }