aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-12 12:48:27 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-12 12:56:03 -0700
commit74616cdddfd0f46822be8708f7bad0038fdca526 (patch)
treeab24dfa4a16d1dac1e7c5381ba5fb1c60fe4613b /qt-ui
parentf9b18b9bfbdd3ef89750cd9b231d57df550db28b (diff)
downloadsubsurface-74616cdddfd0f46822be8708f7bad0038fdca526.tar.gz
Rename event: correctly replace event with new one
I don't like that the event structure includes the variable length array. That really makes it a pain to change the name of an event (on the flip side, freeing events is easier I guess). Anyway, to correctly rename an event we need to actually remove the event from the correct dc and then add a new event with the new name. The previous code was insane (it only worked if the new name was of smaller or equal length, otherwise it had a beautiful buffer overflow). And of course we need to do this both for the current_dive and the displayed_dive. Fixes #616 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index dfe514f28..6c1991aee 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1093,10 +1093,14 @@ void ProfileWidget2::editName()
lengthWarning.exec();
return;
}
- strcpy(event->name, newName.toUtf8());
- remember_event(event->name);
+ // order is important! first update the current dive (by matching the unchanged event),
+ // then update the displayed dive (as event is part of the events on displayed dive
+ // and will be freed as part of changing the name!
+ update_event_name(current_dive, event, newName.toUtf8().data());
+ update_event_name(&displayed_dive, event, newName.toUtf8().data());
+ mark_divelist_changed(true);
+ replot();
}
- replot();
}
void ProfileWidget2::disconnectTemporaryConnections()