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>
This commit is contained in:
Dirk Hohndel 2017-02-21 18:18:44 -08:00
parent 3fef6ec31d
commit da50bb1ae5

View file

@ -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); interleave_dive_computers(&res->dc, &a->dc, &b->dc, offset);
else else
join_dive_computers(&res->dc, &a->dc, &b->dc, 0); 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); fixup_dive(res);
return res; return res;
} }