summaryrefslogtreecommitdiffstats
path: root/qt-models/divelocationmodel.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-04 08:45:45 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-04 08:45:45 -0700
commitf8a3a8521003a26525b658840ce8e7bfd3f7b141 (patch)
treeec99f02c732c3c39fbf9e2dbae7dc0ec4689fdd6 /qt-models/divelocationmodel.cpp
parent37aebe0b2e584c4d63e5c01c9bab0e1a8385acf1 (diff)
downloadsubsurface-f8a3a8521003a26525b658840ce8e7bfd3f7b141.tar.gz
Fix potential crash using std::sort
It's entirely unclear why std::sort sometimes accesses the element with index -1. In my limited testing switching to qSort avoids that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r--qt-models/divelocationmodel.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index 234b4f16c..c917cddf1 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -44,7 +44,7 @@ void LocationInformationModel::update()
{
beginResetModel();
internalRowCount = dive_site_table.nr;
- std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
+ qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
endResetModel();
}
@@ -55,8 +55,8 @@ int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int
longitude.udeg = lon;
beginInsertRows(QModelIndex(), dive_site_table.nr, dive_site_table.nr);
- int32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude);
- std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
+ uint32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude);
+ qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
internalRowCount = dive_site_table.nr;
endInsertRows();
return uuid;