summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-08 23:24:44 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-08 23:24:44 -0700
commit8e8a631cbc354e47c94913f4e82295cea13b3892 (patch)
tree10bdb255081d95f2d1c98c0ecb711ca0a0c1fbd3 /qt-ui/maintab.cpp
parent2e43769108d4023c215451fa8116abdc991e0f19 (diff)
downloadsubsurface-8e8a631cbc354e47c94913f4e82295cea13b3892.tar.gz
Fix crash when cancelling 'Add Dive'
If selected_dive is -1 get_dive(selected_dive) will return NULL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 5dcd09062..d753379c7 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -559,9 +559,14 @@ void MainTab::rejectChanges()
mydive->weightsystem[i] = notesBackup[mydive].weightsystem[i];
}
}
- multiEditEquipmentPlaceholder = *get_dive(selected_dive);
- cylindersModel->setDive(&multiEditEquipmentPlaceholder);
- weightModel->setDive(&multiEditEquipmentPlaceholder);
+ if (selected_dive > 0) {
+ multiEditEquipmentPlaceholder = *get_dive(selected_dive);
+ cylindersModel->setDive(&multiEditEquipmentPlaceholder);
+ weightModel->setDive(&multiEditEquipmentPlaceholder);
+ } else {
+ cylindersModel->clear();
+ weightModel->clear();
+ }
}
ui.diveNotesMessage->animatedHide();