From aedbde1e8683b2643e29040c849c39bec4d00a22 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 29 Sep 2015 20:58:57 -0400 Subject: [PATCH] Delete unused dive sites after edit This way they don't continue to clutter the globe. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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