diff options
-rw-r--r-- | qt-models/divelistmodel.cpp | 9 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 4 | ||||
-rw-r--r-- | subsurface-helper.cpp | 2 |
3 files changed, 5 insertions, 10 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 39f8fbc47..6d94b09c9 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -140,11 +140,9 @@ QString DiveListSortModel::tripShortDate(const QString §ion) return QStringLiteral("%1\n'%2").arg(firstMonth,firstTime.toString("yy")); } -DiveListModel *DiveListModel::m_instance = NULL; - -DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent) +DiveListModel::DiveListModel() { - m_instance = this; + LOG_STP("run_ui diveListModel started"); } void DiveListModel::insertDive(int i) @@ -297,7 +295,8 @@ QString DiveListModel::startAddDive() DiveListModel *DiveListModel::instance() { - return m_instance; + static DiveListModel self; + return &self; } struct dive *DiveListModel::getDive(int i) diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index 19838f468..87c5bb254 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -46,7 +46,7 @@ public: }; static DiveListModel *instance(); - DiveListModel(QObject *parent = 0); + DiveListModel(); void addDive(const QList<dive *> &listOfDives); void addAllDives(); void insertDive(int i); @@ -64,8 +64,6 @@ public: void resetInternalData(); void clear(); // Clear all dives in core Q_INVOKABLE DiveObjectHelper at(int i); -private: - static DiveListModel *m_instance; }; #endif // DIVELISTMODEL_H diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 63096e22a..1a0473b40 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -96,8 +96,6 @@ void run_ui() qDebug() << "QML import path" << engine.importPathList(); #endif // __APPLE__ not Q_OS_IOS engine.addImportPath("qrc://imports"); - DiveListModel diveListModel; - LOG_STP("run_ui diveListModel started"); DiveListSortModel *sortModel = new DiveListSortModel(0); GpsListModel gpsListModel; QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(nullptr); |