mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
188e513761
commit
3b42de66dc
2 changed files with 3 additions and 11 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue