From 156e0530500ff8e21a0ae2245aabbd3057fbe1d6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 29 Aug 2018 20:30:01 +0200 Subject: 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 --- desktop-widgets/divelistview.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'desktop-widgets') 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 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); -- cgit v1.2.3-70-g09d2