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>
This commit is contained in:
Dirk Hohndel 2014-06-28 13:42:38 -07:00
parent 413c276258
commit 3ef490fe11

View file

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