aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-28 13:42:38 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-28 13:42:38 -0700
commit3ef490fe118104e90d8eda39b2f15e1b1be409db (patch)
tree6b46bde2ffca4c06a16d83209ed54e6af983307f /qt-ui
parent413c276258997bbb71ccdc20b6b328a58b9d8851 (diff)
downloadsubsurface-3ef490fe118104e90d8eda39b2f15e1b1be409db.tar.gz
Fix crash when cancelling a trip edit
We were comparing the wrong data and freeing things that shouldn't be freed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 6f9be07b8..b3514e4f2 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -843,14 +843,20 @@ void MainTab::rejectChanges()
}
}
// now let's avoid memory leaks
- struct dive *cd = current_dive;
- FREE_IF_DIFFERENT(tag_list);
- FREE_IF_DIFFERENT(location);
- FREE_IF_DIFFERENT(buddy);
- FREE_IF_DIFFERENT(divemaster);
- FREE_IF_DIFFERENT(notes);
- FREE_IF_DIFFERENT(suit);
-
+ if (MainWindow::instance() && MainWindow::instance()->dive_list()->selectedTrips().count() == 1) {
+ if (editedDive.location != current_dive->divetrip->location)
+ free(editedDive.location);
+ if (editedDive.notes != current_dive->divetrip->notes)
+ free(editedDive.notes);
+ } else {
+ struct dive *cd = current_dive;
+ FREE_IF_DIFFERENT(tag_list);
+ FREE_IF_DIFFERENT(location);
+ FREE_IF_DIFFERENT(buddy);
+ FREE_IF_DIFFERENT(divemaster);
+ FREE_IF_DIFFERENT(notes);
+ FREE_IF_DIFFERENT(suit);
+ }
hideMessage();
MainWindow::instance()->dive_list()->setEnabled(true);
ui.dateEdit->setEnabled(true);