mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
When merging downloaded dives, strive to keep old dive in 'a'
This doesn't really change the logic of the merging, but it does mean that the end result tends to be less unexpected: when downloading dives that end up being merged with pre-existing dives (because you have multiple dive computers, for example), the newly downloaded dive data will tend to be appended to the old dive data, rather than showing up first. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3d80d9283d
commit
59fc674e01
1 changed files with 8 additions and 5 deletions
13
dive.c
13
dive.c
|
@ -1357,12 +1357,15 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean pr
|
|||
struct dive *res = alloc_dive();
|
||||
struct dive *dl = NULL;
|
||||
|
||||
if (prefer_downloaded) {
|
||||
if (a->downloaded)
|
||||
dl = a;
|
||||
else if (b->downloaded)
|
||||
dl = b;
|
||||
/* Aim for newly downloaded dives to be 'b' (keep old dive data first) */
|
||||
if (a->downloaded && !b->downloaded) {
|
||||
struct dive *tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
if (prefer_downloaded && b->downloaded)
|
||||
dl = b;
|
||||
|
||||
res->when = dl ? dl->when : a->when;
|
||||
res->selected = a->selected || b->selected;
|
||||
merge_trip(res, a, b);
|
||||
|
|
Loading…
Reference in a new issue