diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-09-29 20:58:57 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-29 20:58:57 -0400 |
commit | aedbde1e8683b2643e29040c849c39bec4d00a22 (patch) | |
tree | db33ab88a7b573046df3a57eda271edfd40e0bc8 /qt-ui/maintab.cpp | |
parent | 1b8ac21f6be42d777f38d1cf921bcadcb11f82f8 (diff) | |
download | subsurface-aedbde1e8683b2643e29040c849c39bec4d00a22.tar.gz |
Delete unused dive sites after edit
This way they don't continue to clutter the globe.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ffa5d82d6..e7b6a33b3 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1054,11 +1054,19 @@ void MainTab::acceptChanges() } // update the dive site for the selected dives that had the same dive site as the current dive + uint32_t oldUuid = cd->dive_site_uuid; MODIFY_SELECTED_DIVES( if (mydive->dive_site_uuid == current_dive->dive_site_uuid) updateDiveSite(get_idx_by_uniq_id(mydive->id)); ); - + if (!is_dive_site_used(oldUuid, false)) { + if (verbose) { + struct dive_site *ds = get_dive_site_by_uuid(oldUuid); + qDebug() << "delete now unused dive site" << ((ds && ds->name) ? ds->name : "without name"); + } + delete_dive_site(oldUuid); + GlobeGPS::instance()->reload(); + } // the code above can change the correct uuid for the displayed dive site - and the // code below triggers an update of the display without re-initializing displayed_dive // so let's make sure here that our data is consistent now that we have handled the |