summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-13 23:22:40 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-13 23:22:40 -0800
commit6820b13bd58ee382a21215e84427dfd690857dd6 (patch)
treeff4bb030e3a15122a3fe3965b570e9246365e022 /save-xml.c
parentca72ab574904bc7fe8083bb692f58d4647e2ff61 (diff)
downloadsubsurface-6820b13bd58ee382a21215e84427dfd690857dd6.tar.gz
Don't store empty dive sites
And remove references to them from the dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/save-xml.c b/save-xml.c
index 5a0c6976c..c09b90812 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -506,6 +506,17 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
put_format(b, "<divesites>\n");
for (i = 0; i < dive_site_table.nr; i++) {
struct dive_site *ds = get_dive_site(i);
+ if (dive_site_is_empty(ds)) {
+ int j;
+ struct dive *d;
+ for_each_dive(j, d) {
+ if (d->dive_site_uuid == ds->uuid)
+ d->dive_site_uuid = 0;
+ }
+ delete_dive_site(get_dive_site(i)->uuid);
+ i--; // since we just deleted that one
+ continue;
+ }
put_format(b, "<site uuid='%8x' ", ds->uuid);
show_utf8(b, ds->name, " name='", "'", 1);
if (ds->latitude.udeg || ds->longitude.udeg) {