summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-21 18:18:44 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-21 18:22:56 -0800
commitda50bb1ae5b93d32592d0733bb1b33c0725a1a90 (patch)
tree257bedecb4a55e522625bbc8dfe46f34e518e8b7 /core/dive.c
parent3fef6ec31da786bde7f249dd9c07121944ddd9ee (diff)
downloadsubsurface-da50bb1ae5b93d32592d0733bb1b33c0725a1a90.tar.gz
Dive merge: don't pick an empty dive site
When merging, we should treat an empty dive site (which will be deleted on save) the same as not having a dive site. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/dive.c b/core/dive.c
index 58b92b5cc..48dd929f4 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -3167,7 +3167,11 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer
interleave_dive_computers(&res->dc, &a->dc, &b->dc, offset);
else
join_dive_computers(&res->dc, &a->dc, &b->dc, 0);
- res->dive_site_uuid = a->dive_site_uuid ?: b->dive_site_uuid;
+ /* we take the first dive site, unless it's empty */
+ if (a->dive_site_uuid && !dive_site_is_empty(get_dive_site_by_uuid(a->dive_site_uuid)))
+ res->dive_site_uuid = a->dive_site_uuid;
+ else
+ res->dive_site_uuid = b->dive_site_uuid;
fixup_dive(res);
return res;
}