aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-05-28 19:03:10 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-28 17:03:47 -0700
commitc3306c39f13519441ba2ebd1bbe068fc910e0592 (patch)
treeec686280ff65e29639a3f5b9992ea3029b0cdb9a /qt-ui/maintab.cpp
parent86d7f6ace06adf13fe5045a217c4f264356a01df (diff)
downloadsubsurface-c3306c39f13519441ba2ebd1bbe068fc910e0592.tar.gz
Fix crash on adding / removing a dives from add menu
This patch removes some inconsistencies that were happening on the add dive / cancel actions. a bit of legacy code from the old system was still in, which made things quite... EXPLOSIVE. This fixes restoring the selection only if we have a selection and not deleting the temporary dive twice. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 850528192..ec3c38996 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -804,24 +804,27 @@ void MainTab::rejectChanges()
if (lastMode == ADD) {
// clean up
DivePlannerPointsModel::instance()->cancelPlan();
+ hideMessage();
+ resetPallete();
+ return;
} else if (lastMode == MANUALLY_ADDED_DIVE) {
// when we tried to edit a manually added dive, we destroyed
// the dive we edited, so let's just restore it from backup
DivePlannerPointsModel::instance()->restoreBackupDive();
}
struct dive *curr = current_dive;
- ui.notes->setText(notesBackup[curr].notes);
- ui.location->setText(notesBackup[curr].location);
- ui.buddy->setText(notesBackup[curr].buddy);
- ui.suit->setText(notesBackup[curr].suit);
- ui.divemaster->setText(notesBackup[curr].divemaster);
- ui.rating->setCurrentStars(notesBackup[curr].rating);
- ui.visibility->setCurrentStars(notesBackup[curr].visibility);
- ui.airtemp->setText(notesBackup[curr].airtemp);
- ui.watertemp->setText(notesBackup[curr].watertemp);
- ui.tagWidget->setText(notesBackup[curr].tags);
- // it's a little harder to do the right thing for the date time widget
if (curr) {
+ ui.notes->setText(notesBackup[curr].notes);
+ ui.location->setText(notesBackup[curr].location);
+ ui.buddy->setText(notesBackup[curr].buddy);
+ ui.suit->setText(notesBackup[curr].suit);
+ ui.divemaster->setText(notesBackup[curr].divemaster);
+ ui.rating->setCurrentStars(notesBackup[curr].rating);
+ ui.visibility->setCurrentStars(notesBackup[curr].visibility);
+ ui.airtemp->setText(notesBackup[curr].airtemp);
+ ui.watertemp->setText(notesBackup[curr].watertemp);
+ ui.tagWidget->setText(notesBackup[curr].tags);
+ // it's a little harder to do the right thing for the date time widget
ui.dateTimeEdit->setDateTime(QDateTime::fromString(notesBackup[curr].datetime));
} else {
QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit *>();
@@ -854,12 +857,6 @@ void MainTab::rejectChanges()
}
}
updateGpsCoordinates(curr);
- if (lastMode == ADD) {
- delete_single_dive(selected_dive);
- MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT);
- MainWindow::instance()->dive_list()->restoreSelection();
- emit addDiveFinished();
- }
if (selected_dive >= 0) {
multiEditEquipmentPlaceholder = *get_dive(selected_dive);
cylindersModel->setDive(&multiEditEquipmentPlaceholder);
@@ -873,17 +870,15 @@ void MainTab::rejectChanges()
hideMessage();
MainWindow::instance()->dive_list()->setEnabled(true);
- notesBackup.clear();
resetPallete();
MainWindow::instance()->globe()->reload();
- if (lastMode == ADD || lastMode == MANUALLY_ADDED_DIVE) {
+ if (lastMode == MANUALLY_ADDED_DIVE) {
// more clean up
updateDiveInfo(selected_dive);
MainWindow::instance()->showProfile();
// we already reloaded the divelist above, so don't recreate it or we'll lose the selection
MainWindow::instance()->refreshDisplay(false);
}
- DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING);
MainWindow::instance()->dive_list()->setFocus();
// the user could have edited the location and then canceled the edit
// let's get the correct location back in view