summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/maintab.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e9da1a53a..9b4166b35 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -815,18 +815,6 @@ void MainTab::updateDisplayedDiveSite()
qDebug() << "Updating Displayed Dive Site";
-#if 0
- // this code is special casing for divesites that were downloaded from the webservice
- if(current_dive) {
- struct dive_site *ds_from_dive = get_dive_site_by_uuid(current_dive->dive_site_uuid);
- if (!dive_site_has_gps_location(ds_from_dive) &&
- same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) {
- ds_from_dive->latitude = displayed_dive_site.latitude;
- ds_from_dive->longitude = displayed_dive_site.longitude;
- delete_dive_site(displayed_dive_site.uuid);
- }
- }
-#endif
if(orig_uuid) {
if (new_uuid && orig_uuid != new_uuid) {
// the user picked a different site
@@ -908,6 +896,16 @@ void MainTab::updateDiveSite(int divenr)
newDs->uuid = createdUuid; // the copy overwrote the uuid
cd->dive_site_uuid = createdUuid;
qDebug() << "create a new dive site with name" << newName << "which is now named" << newDs->name << "and assign it as uuid" << createdUuid;
+ qDebug() << "original dive had site" << origUuid << "and" << (origDs ? QString("notes %1").arg(origDs->notes) : QString("no dive site"));
+ if (origDs && 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)) {
+ qDebug() << "delete the autogenerated dive site" << origDs->name;
+ delete_dive_site(origDs->uuid);
+ free(newDs->notes);
+ newDs->notes = NULL;
+ }
+ }
} else {
qDebug() << "switched to dive site" << newName << "uuid" << newUuid << "for current dive";
cd->dive_site_uuid = newUuid;