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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2023-02-12 16:18:17 +01:00 committed by Dirk Hohndel
parent 0d3c9954f4
commit 4128fec1ea
2 changed files with 3 additions and 2 deletions

View file

@ -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;
}

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "event.h"
#include "eventname.h"
#include "subsurface-string.h"
#include <string.h>
@ -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;
}