diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-07-18 18:42:01 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-07-19 02:43:08 +0300 |
commit | b51e616b6a2af91f63cfa32d641d5898b10314ff (patch) | |
tree | 94d59245a3c09d829c258c84e5b3fd829ad1f60b /desktop-widgets | |
parent | 6c95714b9fc6af72b6d82564ac6f7f7148b8e5ed (diff) | |
download | subsurface-b51e616b6a2af91f63cfa32d641d5898b10314ff.tar.gz |
Undo: clear list of trips to be recreated in UndoDeleteDive::undo()
UndoDeleteDive::tripList kept track of the trips to be recreated on
undo. But the list wasn't cleared on undo, thus on subsequent redo
the same trip was readded to the list, leading to double-free.
This could trivially be reproduced by repeated CTRL-Z, CTRL-SHIFT-Z
pairs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/undocommands.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/desktop-widgets/undocommands.cpp b/desktop-widgets/undocommands.cpp index 2ac046d1c..0c1a4b541 100644 --- a/desktop-widgets/undocommands.cpp +++ b/desktop-widgets/undocommands.cpp @@ -33,6 +33,7 @@ void UndoDeleteDive::undo() record_dive(diveList.at(i)); } mark_divelist_changed(true); + tripList.clear(); MainWindow::instance()->refreshDisplay(); } @@ -56,9 +57,10 @@ void UndoDeleteDive::redo() undo_trip->dives = NULL; // update all the dives who were in this trip to point to the copy of the // trip that we are about to delete implicitly when deleting its last dive below - Q_FOREACH(struct dive *inner_dive, newList) + Q_FOREACH(struct dive *inner_dive, newList) { if (inner_dive->divetrip == d->divetrip) inner_dive->divetrip = undo_trip; + } d->divetrip = undo_trip; tripList.append(undo_trip); } |