mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
2d87a657d2
commit
156e053050
1 changed files with 4 additions and 1 deletions
|
@ -684,9 +684,12 @@ void DiveListView::removeFromTrip()
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
QMap<struct dive*, dive_trip*> divesToRemove;
|
QMap<struct dive*, dive_trip*> divesToRemove;
|
||||||
for_each_dive (i, d) {
|
for_each_dive (i, d) {
|
||||||
if (d->selected)
|
if (d->selected && d->divetrip)
|
||||||
divesToRemove.insert(d, d->divetrip);
|
divesToRemove.insert(d, d->divetrip);
|
||||||
}
|
}
|
||||||
|
if (divesToRemove.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
UndoRemoveDivesFromTrip *undoCommand = new UndoRemoveDivesFromTrip(divesToRemove);
|
UndoRemoveDivesFromTrip *undoCommand = new UndoRemoveDivesFromTrip(divesToRemove);
|
||||||
MainWindow::instance()->undoStack->push(undoCommand);
|
MainWindow::instance()->undoStack->push(undoCommand);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue