From 3ef490fe118104e90d8eda39b2f15e1b1be409db Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 28 Jun 2014 13:42:38 -0700 Subject: 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 --- qt-ui/maintab.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'qt-ui/maintab.cpp') 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); -- cgit v1.2.3-70-g09d2