summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-12-07 09:22:35 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-07 10:18:30 -0800
commit59fc674e015dd8a333a495b769adc052cf6b865c (patch)
tree573bf4123ed240a9a7a1118314f20bf09929962a /dive.c
parent3d80d9283daa82847eb0fe1ae2f9879e9a80c9e5 (diff)
downloadsubsurface-59fc674e015dd8a333a495b769adc052cf6b865c.tar.gz
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>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/dive.c b/dive.c
index 9e44345cf..5edb6087f 100644
--- a/dive.c
+++ b/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);