summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-24 10:37:18 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-25 10:43:48 -0700
commite03b553e80a00b07757f51f7866bc666b807dce8 (patch)
tree5c3ec6d5cc5bdc556f01d4a524a3df44113fbbb4 /qt-ui
parent6eed3155e6a84f1b27b5340b45d6deb801fee42d (diff)
downloadsubsurface-e03b553e80a00b07757f51f7866bc666b807dce8.tar.gz
Make created dive site uuid deterministic
Having random uuids seemed like a good idea, but there are several situations where they really cause problems. One is merging dive file imports from V2 logfiles. Another is testing such imports. Instead of making the uuid random we now hash the name and add the timestamp of the first dive associated with this dive site to the hash (first in this context is "first encountered" with no guarantee that it is the chronologically first). This way V2 imports create deterministic uuids but uuid conflicts are still extremely unlikely, even if the user has multiple dive sites with the same name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 443837a47..c200b36be 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -897,7 +897,7 @@ void MainTab::updateDiveSite(int divenr)
cd->dive_site_uuid = pickedUuid;
} else if (!newName.isEmpty()) {
// user entered a name but didn't pick a dive site, so copy that data
- uint32_t createdUuid = create_dive_site(displayed_dive_site.name);
+ uint32_t createdUuid = create_dive_site(displayed_dive_site.name, cd->when);
struct dive_site *newDs = get_dive_site_by_uuid(createdUuid);
copy_dive_site(&displayed_dive_site, newDs);
newDs->uuid = createdUuid; // the copy overwrote the uuid
@@ -914,7 +914,7 @@ void MainTab::updateDiveSite(int divenr)
} else if (newName != origName) {
if (newUuid == 0) {
// so we created a new site, add it to the global list
- uint32_t createdUuid = create_dive_site(displayed_dive_site.name);
+ uint32_t createdUuid = create_dive_site(displayed_dive_site.name, cd->when);
struct dive_site *newDs = get_dive_site_by_uuid(createdUuid);
copy_dive_site(&displayed_dive_site, newDs);
newDs->uuid = createdUuid; // the copy overwrote the uuid