From 5707554e98eab431c1b2c50bf13c51770ff38db8 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Tue, 12 Dec 2017 14:48:41 +0100 Subject: mobile: do not just create a new dive site This fixes an annoying bug. When entering an existing divesite in the mobile app, always a new divesite (with same name) was created, resulting in multiple sites on the same gps location. So, be more carefull in checking and creating a new site. Signed-off-by: Jan Mulder --- mobile-widgets/qmlmanager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mobile-widgets/qmlmanager.cpp') diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 85c606cd0..37254f7cf 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -814,12 +814,16 @@ parsed: bool QMLManager::checkLocation(DiveObjectHelper *myDive, struct dive *d, QString location, QString gps) { bool diveChanged = false; - - struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid); + uint32_t uuid; + struct dive_site *ds = get_dive_site_for_dive(d); if (myDive->location() != location) { diveChanged = true; - ds = get_dive_site_by_uuid(create_dive_site(qPrintable(location), d->when)); - d->dive_site_uuid = ds->uuid; + if (!ds) { + uuid = get_dive_site_uuid_by_name(qPrintable(location), NULL); + if (!uuid) + uuid = create_dive_site(qPrintable(location), d->when); + } + d->dive_site_uuid = uuid; } // now make sure that the GPS coordinates match - if the user changed the name but not // the GPS coordinates, this still does the right thing as the now new dive site will -- cgit v1.2.3-70-g09d2