diff options
author | Jan Mulder <jlmulder@xs4all.nl> | 2017-12-12 14:48:41 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-13 05:05:49 -0800 |
commit | 5707554e98eab431c1b2c50bf13c51770ff38db8 (patch) | |
tree | 0ca14da1c43f4a90b2c03ffc511561a629370912 /mobile-widgets/qmlmanager.cpp | |
parent | 3a64d8a481665189f95dcb9ce33dae51088af42e (diff) | |
download | subsurface-5707554e98eab431c1b2c50bf13c51770ff38db8.tar.gz |
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 <jlmulder@xs4all.nl>
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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 |