mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix "prefer download" behavior
When this was first implemented the assumption was that a downloaded dive that is to be merged with an existing dive would have the same time stamp. But as Linus pointed out even back then, this does fail if a dive has been merged with a download from a different dive computer before (think: download from computer a, then download same dive from b, then improve something in the parsing from computer a and try to redownload; the time stamp could have changed). This commit also fixes a silly omission in the merge_dives() function (which ended up ALWAYS prefering the downloaded dive) and finally implements the necessary changes to mark dives downloaded from a Uemis SDA as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d872a5c8aa
commit
10ce60e212
5 changed files with 14 additions and 11 deletions
12
dive.c
12
dive.c
|
@ -1077,8 +1077,6 @@ struct dive *try_to_merge(struct dive *a, struct dive *b, gboolean prefer_downlo
|
|||
*/
|
||||
if ((a->when >= b->when + 60) || (a->when <= b->when - 60))
|
||||
return NULL;
|
||||
if (prefer_downloaded && a->when != b->when)
|
||||
return NULL;
|
||||
if (!prefer_downloaded) {
|
||||
/* Dive 'a' is 'offset' seconds before dive 'b' */
|
||||
offset = find_sample_offset(a, b);
|
||||
|
@ -1093,10 +1091,12 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean pr
|
|||
struct dive *res = alloc_dive();
|
||||
struct dive *dl = NULL;
|
||||
|
||||
if (a->downloaded)
|
||||
dl = a;
|
||||
else if (b->downloaded)
|
||||
dl = b;
|
||||
if (prefer_downloaded) {
|
||||
if (a->downloaded)
|
||||
dl = a;
|
||||
else if (b->downloaded)
|
||||
dl = b;
|
||||
}
|
||||
res->when = a->when;
|
||||
res->selected = a->selected || b->selected;
|
||||
merge_trip(res, a, b);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue