From da50bb1ae5b93d32592d0733bb1b33c0725a1a90 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 21 Feb 2017 18:18:44 -0800 Subject: [PATCH] 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 --- core/dive.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; }