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>
This commit is contained in:
Dirk Hohndel 2013-10-08 23:24:44 -07:00
parent 2e43769108
commit 8e8a631cbc

View file

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