summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-models/gpslistmodel.cpp8
-rw-r--r--qt-models/gpslistmodel.h3
-rw-r--r--subsurface-helper.cpp3
3 files changed, 5 insertions, 9 deletions
diff --git a/qt-models/gpslistmodel.cpp b/qt-models/gpslistmodel.cpp
index 8d874d67b..33eb8a5ea 100644
--- a/qt-models/gpslistmodel.cpp
+++ b/qt-models/gpslistmodel.cpp
@@ -3,11 +3,8 @@
#include "core/qthelper.h"
#include <QVector>
-GpsListModel *GpsListModel::m_instance = NULL;
-
-GpsListModel::GpsListModel(QObject *parent) : QAbstractListModel(parent)
+GpsListModel::GpsListModel()
{
- m_instance = this;
}
void GpsListModel::update()
@@ -65,6 +62,7 @@ QHash<int, QByteArray> GpsListModel::roleNames() const
GpsListModel *GpsListModel::instance()
{
- return m_instance;
+ static GpsListModel self;
+ return &self;
}
diff --git a/qt-models/gpslistmodel.h b/qt-models/gpslistmodel.h
index a1c82e5d6..e705825cc 100644
--- a/qt-models/gpslistmodel.h
+++ b/qt-models/gpslistmodel.h
@@ -20,7 +20,7 @@ public:
};
static GpsListModel *instance();
- GpsListModel(QObject *parent = 0);
+ GpsListModel();
void clear();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QHash<int, QByteArray> roleNames() const;
@@ -28,7 +28,6 @@ public:
void update();
private:
QVector<gpsTracker> m_gpsFixes;
- static GpsListModel *m_instance;
};
#endif // GPSLISTMODEL_H
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp
index 1a0473b40..26e58ece9 100644
--- a/subsurface-helper.cpp
+++ b/subsurface-helper.cpp
@@ -97,9 +97,8 @@ void run_ui()
#endif // __APPLE__ not Q_OS_IOS
engine.addImportPath("qrc://imports");
DiveListSortModel *sortModel = new DiveListSortModel(0);
- GpsListModel gpsListModel;
QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(nullptr);
- gpsSortModel->setSourceModel(&gpsListModel);
+ gpsSortModel->setSourceModel(GpsListModel::instance());
gpsSortModel->setDynamicSortFilter(true);
gpsSortModel->setSortRole(GpsListModel::GpsWhenRole);
gpsSortModel->sort(0, Qt::DescendingOrder);