diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-08-29 20:30:01 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-29 21:38:48 -0700 |
commit | 156e0530500ff8e21a0ae2245aabbd3057fbe1d6 (patch) | |
tree | 03c18d3538685d26319ea836aad744d5959d9f43 /desktop-widgets | |
parent | 2d87a657d248c1c6d4dd6a805bbf90c98589798a (diff) | |
download | subsurface-156e0530500ff8e21a0ae2245aabbd3057fbe1d6.tar.gz |
Dive trips: don't crash on repeated trip-removal
In the UI it is possible to remove a dive from a trip twice,
which leads to a crash, because trip is NULL (obviously).
Instead of doing a proper fix (don't show the "remove from
trip" entry in the first place), ignore dives without a
trip, since a rewrite of the undo-code is planned for the
medium future anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index a6f1531af..eb225e593 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -684,9 +684,12 @@ void DiveListView::removeFromTrip() struct dive *d; QMap<struct dive*, dive_trip*> divesToRemove; for_each_dive (i, d) { - if (d->selected) + if (d->selected && d->divetrip) divesToRemove.insert(d, d->divetrip); } + if (divesToRemove.isEmpty()) + return; + UndoRemoveDivesFromTrip *undoCommand = new UndoRemoveDivesFromTrip(divesToRemove); MainWindow::instance()->undoStack->push(undoCommand); |