From 7426f18a960b7c397842f45a5e0ca72942d04c36 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 23 Sep 2015 17:05:31 -0300 Subject: Handles Dive Selection gracefully Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index c74ef527e..884ef547d 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -868,13 +868,19 @@ void MainTab::updateDiveSite(int divenr) uint32_t pickedUuid = ui.location->currDiveSiteUuid(); const uint32_t origUuid = cd->dive_site_uuid; struct dive_site *origDs = get_dive_site_by_uuid(origUuid); + struct dive_site *newDs = NULL; + + if (pickedUuid == origUuid) { + return; + } if (pickedUuid == RECENTLY_ADDED_DIVESITE) { pickedUuid = create_dive_site(ui.location->text().isEmpty() ? qPrintable(tr("New dive site")) : qPrintable(ui.location->text()), displayed_dive.when); - struct dive_site *newDs = get_dive_site_by_uuid(pickedUuid); - copy_dive_site(newDs, &displayed_dive_site); } + newDs = get_dive_site_by_uuid(pickedUuid); + copy_dive_site(newDs, &displayed_dive_site); + if (origDs && pickedUuid != origDs->uuid && same_string(origDs->notes, "SubsurfaceWebservice")) { // this is a special case - let's remove the original dive site if this was the only user if (!is_dive_site_used(origDs->uuid, false)) { -- cgit v1.2.3-70-g09d2