Dive site: set UUID only on save or load

Since the UUID will be overwritten on save and is only used on save
and load, set it only on save or load. For other created dive sites,
leave the UUID field uninitialized.

This means that the UUID will change between saves. Let's see how
the git saver handles that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-03-03 18:39:12 +01:00 committed by Dirk Hohndel
parent ac1602f512
commit 31291b1c56
16 changed files with 40 additions and 65 deletions

View file

@ -658,17 +658,15 @@ struct dive_site *MainTab::updateDiveSite(struct dive_site *pickedDs, dive *d)
if (pickedDs == RECENTLY_ADDED_DIVESITE) {
QString name = ui.location->text();
pickedDs = create_dive_site(qPrintable(name), displayed_dive.when, &dive_site_table);
pickedDs = create_dive_site(qPrintable(name), &dive_site_table);
createdNewDive = true;
}
if (origDs) {
if(createdNewDive) {
uint32_t pickedUuid = pickedDs->uuid;
copy_dive_site(origDs, pickedDs);
free(pickedDs->name);
pickedDs->name = copy_qstring(ui.location->text());
pickedDs->uuid = pickedUuid;
qDebug() << "Creating and copying dive site";
} else if (!has_location(&pickedDs->location)) {
pickedDs->location = origDs->location;