diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-06-26 20:27:45 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-26 18:50:23 -0700 |
commit | 7763b95e5f0929fcdfaba95f69dff28950f5486a (patch) | |
tree | de8da815f073b4135eee93d969bc0a49a5ef8613 /qt-ui | |
parent | 0592771005606f8c5214b319eb3dac41c3dd4537 (diff) | |
download | subsurface-7763b95e5f0929fcdfaba95f69dff28950f5486a.tar.gz |
Dive site rewrite: fix potential crash
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e61c92a3e..9022625f7 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -498,7 +498,8 @@ void MainTab::updateDiveInfo(bool clear) if (ds) { ui.location->setText(ds->name); ui.locationTags->setText(ds->description); // TODO: This should be three tags following davide's explanation. - copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); + if (displayed_dive.dive_site_uuid) + copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); } else { ui.location->clear(); clear_dive_site(&displayed_dive_site); @@ -800,7 +801,8 @@ void MainTab::acceptChanges() struct dive *added_dive = clone_dive(&displayed_dive); record_dive(added_dive); addedId = added_dive->id; - copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid)); + if (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 // dive - we'll have to undo/redo this later after we resort the dive_table @@ -860,7 +862,8 @@ void MainTab::acceptChanges() saveTaggedStrings(); saveTags(); - copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid)); + if (displayed_dive_site.uuid) + copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid)); if (editMode != ADD && cylindersModel->changed) { mark_divelist_changed(true); |