From bf65f1e507c508428e46b06152d08494b426f69f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 26 Nov 2017 23:48:41 +0100 Subject: Fix comparison function in qt-models/divelocationmodel.cpp The function dive_site_less_than() in qt-models/divelocationmodel.cpp does not what it promises: it uses less-or-equal instead of less-than comparison. Note that, even though this may sound pedantic, this is an actual bug. Usually, sorting functions suppose that they are provided with strict weak ordering, which <= does *not* provide. This is the actual reason for the crash mentioned in commit f8a3a8521003a26525b658840ce8e7bfd3f7b141. While touching this function, make it of static linkage, since its usage is local to this translation unit. Signed-off-by: Berthold Stoeger --- qt-models/divelocationmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 774a9b2d7..794302fe2 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -7,9 +7,9 @@ #include #include -bool dive_site_less_than(dive_site *a, dive_site *b) +static bool dive_site_less_than(dive_site *a, dive_site *b) { - return QString(a->name) <= QString(b->name); + return QString(a->name) < QString(b->name); } LocationInformationModel *LocationInformationModel::instance() -- cgit v1.2.3-70-g09d2