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
f8a3a85210.

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>
This commit is contained in:
Berthold Stoeger 2017-11-26 23:48:41 +01:00 committed by Dirk Hohndel
parent d1545b27b4
commit bf65f1e507

View file

@ -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()