summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-08 09:45:09 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-08 09:45:09 -0700
commita29f897125878e25e3d47b98d499a68970154004 (patch)
treef5687b8319aab8a9cc8a3aa95c1537eff374d754 /save-xml.c
parent4f3a9ba58309e5fc207733edcf01077f78ddf380 (diff)
downloadsubsurface-a29f897125878e25e3d47b98d499a68970154004.tar.gz
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>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/save-xml.c b/save-xml.c
index 778218fa4..6921e3b2e 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -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));