diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-11-26 23:48:41 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-11-26 18:49:05 -0800 |
commit | bf65f1e507c508428e46b06152d08494b426f69f (patch) | |
tree | dc885f43d0810d9c57880d1d41f84a56c48ecaf8 | |
parent | d1545b27b45db1b06cad56eb366757208dfa120b (diff) | |
download | subsurface-bf65f1e507c508428e46b06152d08494b426f69f.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | qt-models/divelocationmodel.cpp | 4 |
1 files 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 <QIcon> #include <core/gettextfromc.h> -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() |