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>
This commit is contained in:
Berthold Stoeger 2018-08-29 20:30:01 +02:00 committed by Dirk Hohndel
parent 2d87a657d2
commit 156e053050

View file

@ -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);