Use (and update) dive computer times when merging and splitting dives

When we split a dive in two, we keep the dive computer ID for the dive,
but we should update the actual _time_ of the split dive to match the
split.

And when we look for "are these the exact same dives", we should check
not only that the dive computer dive ID matches, but also that the dive
computer time matches, so that we don't consider two parts of a dive
that has been split to be obviously the same dive.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Linus Torvalds 2018-07-01 14:30:34 -07:00 committed by Dirk Hohndel
parent 3209b490dd
commit 90569e0ee6

View file

@ -2701,7 +2701,7 @@ int match_one_dc(struct divecomputer *a, struct divecomputer *b)
* If they have different dive ID's on the same
* dive computer, that's a definite "same or not"
*/
return a->diveid == b->diveid ? 1 : -1;
return a->diveid == b->diveid && a->when == b->when ? 1 : -1;
}
/*
@ -3456,6 +3456,7 @@ static int split_dive_at(struct dive *dive, int a, int b)
*/
t = dc2->sample[0].time.seconds;
d2->when += t;
dc2->when += t;
for (i = 0; i < dc2->samples; i++)
dc2->sample[i].time.seconds -= t;