mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Only store dive site uuid in dive if the dive site exists
Don't store stale uuids. As a side effect this makes it easy to remove dive sites from the XML file (or the git repository) when duplicates have been added for some reason and the user wants to restart from scratch. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4f3a9ba583
commit
a29f897125
2 changed files with 10 additions and 4 deletions
|
@ -403,8 +403,10 @@ static void create_dive_buffer(struct dive *dive, struct membuffer *b)
|
|||
SAVE("visibility", visibility);
|
||||
cond_put_format(dive->tripflag == NO_TRIP, b, "notrip\n");
|
||||
save_tags(b, dive->tag_list);
|
||||
cond_put_format(dive->dive_site_uuid, b, "divesiteid %08x\n", dive->dive_site_uuid);
|
||||
|
||||
cond_put_format(dive->dive_site_uuid && get_dive_site_by_uuid(dive->dive_site_uuid),
|
||||
b, "divesiteid %08x\n", dive->dive_site_uuid);
|
||||
if (verbose && dive->dive_site_uuid && get_dive_site_by_uuid(dive->dive_site_uuid))
|
||||
fprintf(stderr, "removed reference to non-existant dive site with uuid %08x\n", dive->dive_site_uuid);
|
||||
save_overview(b, dive);
|
||||
save_cylinder_info(b, dive);
|
||||
save_weightsystem_info(b, dive);
|
||||
|
|
|
@ -401,8 +401,12 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive)
|
|||
if (dive->visibility)
|
||||
put_format(b, " visibility='%d'", dive->visibility);
|
||||
save_tags(b, dive->tag_list);
|
||||
if (dive->dive_site_uuid)
|
||||
put_format(b, " divesiteid='%8x'", dive->dive_site_uuid);
|
||||
if (dive->dive_site_uuid) {
|
||||
if (get_dive_site_by_uuid(dive->dive_site_uuid) != NULL)
|
||||
put_format(b, " divesiteid='%8x'", dive->dive_site_uuid);
|
||||
else if (verbose)
|
||||
fprintf(stderr, "removed reference to non-existant dive site with uuid %08x\n", dive->dive_site_uuid);
|
||||
}
|
||||
show_date(b, dive->when);
|
||||
put_format(b, " duration='%u:%02u min'>\n",
|
||||
FRACTION(dive->dc.duration.seconds, 60));
|
||||
|
|
Loading…
Add table
Reference in a new issue