profile: remove internal event-copy (fix deleting/renaming events)

The DiveEventItem had an internal copy of the event. It passed
that copy to the undo-machinery, which of course didn't work.

Simply keep a pointer to the event. All changes to a dive no
pass via the undo-machinery, which causes a reload of the profile,
so this should be safe.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-06-05 09:29:41 +02:00 committed by Dirk Hohndel
parent fd2862042b
commit 0b190243dd
4 changed files with 65 additions and 60 deletions

View file

@ -1419,7 +1419,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
if (DiveEventItem *item = dynamic_cast<DiveEventItem *>(sceneItem)) {
m.addAction(tr("Remove event"), [this,item] { removeEvent(item); });
m.addAction(tr("Hide similar events"), [this, item] { hideEvents(item); });
struct event *dcEvent = item->getEvent();
const struct event *dcEvent = item->getEvent();
if (dcEvent->type == SAMPLE_EVENT_BOOKMARK)
m.addAction(tr("Edit name"), [this, item] { editName(item); });
#if 0 // TODO::: FINISH OR DISABLE
@ -1496,7 +1496,7 @@ void ProfileWidget2::makeFirstDC()
void ProfileWidget2::hideEvents(DiveEventItem *item)
{
struct event *event = item->getEvent();
const struct event *event = item->getEvent();
if (QMessageBox::question(this,
TITLE_OR_TEXT(tr("Hide events"), tr("Hide all %1 events?").arg(event->name)),
@ -1529,7 +1529,7 @@ void ProfileWidget2::unhideEvents()
void ProfileWidget2::removeEvent(DiveEventItem *item)
{
struct event *event = item->getEvent();
struct event *event = item->getEventMutable();
if (!event || !d)
return;
@ -1617,7 +1617,7 @@ double ProfileWidget2::getFontPrintScale() const
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::editName(DiveEventItem *item)
{
struct event *event = item->getEvent();
struct event *event = item->getEventMutable();
if (!event || !d)
return;
bool ok;