Dive site rewrite: fix potential crash

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-06-26 20:27:45 -03:00 committed by Dirk Hohndel
parent 0592771005
commit 7763b95e5f

View file

@ -498,6 +498,7 @@ void MainTab::updateDiveInfo(bool clear)
if (ds) { if (ds) {
ui.location->setText(ds->name); ui.location->setText(ds->name);
ui.locationTags->setText(ds->description); // TODO: This should be three tags following davide's explanation. ui.locationTags->setText(ds->description); // TODO: This should be three tags following davide's explanation.
if (displayed_dive.dive_site_uuid)
copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site);
} else { } else {
ui.location->clear(); ui.location->clear();
@ -800,6 +801,7 @@ void MainTab::acceptChanges()
struct dive *added_dive = clone_dive(&displayed_dive); struct dive *added_dive = clone_dive(&displayed_dive);
record_dive(added_dive); record_dive(added_dive);
addedId = added_dive->id; addedId = added_dive->id;
if (displayed_dive_site.uuid)
copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid)); copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid));
// unselect everything as far as the UI is concerned and select the new // unselect everything as far as the UI is concerned and select the new
@ -860,6 +862,7 @@ void MainTab::acceptChanges()
saveTaggedStrings(); saveTaggedStrings();
saveTags(); saveTags();
if (displayed_dive_site.uuid)
copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid)); copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid));
if (editMode != ADD && cylindersModel->changed) { if (editMode != ADD && cylindersModel->changed) {