summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmanager.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-09-22 14:33:33 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-25 13:35:30 -0700
commit05200f9266a4e8e723450abb281c597a48da2e9f (patch)
tree670d7b30f4b77f40e35253243f95fb219d5c7aea /mobile-widgets/qmlmanager.h
parentf20d6187f0135ef3cf7f583785be65012336a99d (diff)
downloadsubsurface-05200f9266a4e8e723450abb281c597a48da2e9f.tar.gz
Cleanup: unify idiosyncratic singletons
The way we handle singletons in QML, QML insists on allocating the objects. This leads to a very idiosyncratic way of handling singletons: The global instance pointer is set in the constructor. Unify all these by implementing a "SillySingleton" template. All of the weird singleton-classes can derive from this template and don't have to bother with reimplementing the instance() function with all the safety-checks, etc. This serves firstly as documentation but also improves debugging as we will now see wanted and unwanted creation and destruction of these weird singletons. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets/qmlmanager.h')
-rw-r--r--mobile-widgets/qmlmanager.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index e47119a71..963c563d7 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -13,13 +13,14 @@
#include "core/btdiscovery.h"
#include "core/gpslocation.h"
#include "core/downloadfromdcthread.h"
+#include "core/singleton.h"
#include "qt-models/divelistmodel.h"
#include "qt-models/completionmodels.h"
#include "qt-models/divelocationmodel.h"
#define NOCLOUD_LOCALSTORAGE format_string("%s/cloudstorage/localrepo[master]", system_default_directory())
-class QMLManager : public QObject {
+class QMLManager : public QObject, public SillySingleton<QMLManager> {
Q_OBJECT
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
Q_PROPERTY(bool locationServiceEnabled MEMBER m_locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
@@ -89,7 +90,6 @@ public:
Q_INVOKABLE void setGitLocalOnly(const bool &value);
Q_INVOKABLE void setFilter(const QString filterText);
- static QMLManager *instance();
Q_INVOKABLE void registerError(QString error);
QString consumeError();
@@ -219,7 +219,6 @@ private:
bool m_verboseEnabled;
GpsLocation *locationProvider;
bool m_loadFromCloud;
- static QMLManager *m_instance;
struct dive *deletedDive;
struct dive_trip *deletedTrip;
QString m_notificationText;