mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Improve dive trip sort comparison function
We do want to compare "loose" dives too, but we need to be a bit careful, and always use the trip date as the primary sort key for any dives that are not in the same trip. Reported-and-tested-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
661a380912
commit
c2bc6633ec
1 changed files with 12 additions and 9 deletions
21
divelist.c
21
divelist.c
|
@ -1461,15 +1461,18 @@ static gint dive_nr_sort(GtkTreeModel *model,
|
||||||
tripb = b->divetrip;
|
tripb = b->divetrip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tripa || !tripb)
|
/*
|
||||||
return 0;
|
* Compare dive dates within the same trip (or when there
|
||||||
if (tripa->when < tripb->when)
|
* are no trips involved at all). But if we have two
|
||||||
return -1;
|
* different trips use the trip dates for comparison
|
||||||
if (tripa->when > tripb->when)
|
*/
|
||||||
return 1;
|
if (tripa != tripb) {
|
||||||
if (a && b)
|
if (tripa)
|
||||||
return a->when - b->when;
|
when_a = tripa->when;
|
||||||
return 0;
|
if (tripb)
|
||||||
|
when_b = tripb->when;
|
||||||
|
}
|
||||||
|
return when_a - when_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue