diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-01-31 09:42:09 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2020-01-31 21:28:45 +0100 |
commit | 3b42de66dc469e8783df2a3ea08e90b310821668 (patch) | |
tree | d3b585d3f3d60dddf324a4b9d8512847318e3075 /mobile-widgets/qmlinterface.cpp | |
parent | 188e513761fb07587b09f90c2d3f043da8870cc9 (diff) | |
download | subsurface-3b42de66dc469e8783df2a3ea08e90b310821668.tar.gz |
Cleanup: remove QMLInterface::instance()
QMLInterface::instance() is only used in one single place. This
makes the whole notion of having a global instance of the object
moot, isn't it?
Simply make the object static to the function that uses it, which
guarantees that the object will be created when the function is
called. I.e. the same behavior is retained with less complexity.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets/qmlinterface.cpp')
-rw-r--r-- | mobile-widgets/qmlinterface.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/mobile-widgets/qmlinterface.cpp b/mobile-widgets/qmlinterface.cpp index 67d4196a3..4bf23dedf 100644 --- a/mobile-widgets/qmlinterface.cpp +++ b/mobile-widgets/qmlinterface.cpp @@ -81,16 +81,11 @@ QMLInterface::QMLInterface() this, &QMLInterface::display_variationsChanged); } -QMLInterface *QMLInterface::instance() -{ - static QMLInterface *self = new QMLInterface; - return self; -} - void QMLInterface::setup(QQmlContext *ct) { // Register interface class - ct->setContextProperty("Backend", QMLInterface::instance()); + static QMLInterface self; + ct->setContextProperty("Backend", &self); // Make enums available as types qmlRegisterUncreatableType<QMLInterface>("org.subsurfacedivelog.mobile",1,0,"Enums","Enum is not a type"); @@ -100,7 +95,6 @@ void QMLInterface::setup(QQmlContext *ct) diveSummary::summaryCalculation(0, 3); } - void QMLInterface::summaryCalculation(int primaryPeriod, int secondaryPeriod) { diveSummary::summaryCalculation(primaryPeriod, secondaryPeriod); |