From 2a9a3dda20c47e74746fbfa3c6e5fd9ee919b2b3 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 28 Sep 2019 23:23:57 +0200 Subject: Cleanup: turn GpsListModel into standard singleton GpsListModel was one of those "special" singletons that could be created explicitly with new. This would make sense if a parameter were passed to the constructor. We only passed null, so one might as well turn that into a classical singleton with default constructor. Signed-off-by: Berthold Stoeger --- qt-models/gpslistmodel.cpp | 8 +++----- qt-models/gpslistmodel.h | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'qt-models') 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 -GpsListModel *GpsListModel::m_instance = NULL; - -GpsListModel::GpsListModel(QObject *parent) : QAbstractListModel(parent) +GpsListModel::GpsListModel() { - m_instance = this; } void GpsListModel::update() @@ -65,6 +62,7 @@ QHash 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 roleNames() const; @@ -28,7 +28,6 @@ public: void update(); private: QVector m_gpsFixes; - static GpsListModel *m_instance; }; #endif // GPSLISTMODEL_H -- cgit v1.2.3-70-g09d2