From 53b216b228165db4a31d122f09e4d481d8ef321b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 30 Mar 2020 21:48:29 +0200 Subject: cleanup: move initialization of QMLInterface QMLInterface was initialized in the register_qml_types function. Therein, it was in an if branch that tested whether the passed-in engine argument was not NULL. However, on mobile this could never be NULL. Let's just move the initialization out of that function. Signed-off-by: Berthold Stoeger --- subsurface-helper.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 96e984520..e87b30574 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -80,6 +80,10 @@ void run_ui() QScreen *appScreen = QApplication::screens().at(0); int availableScreenWidth = appScreen->availableSize().width(); QQmlApplicationEngine engine; + QQmlContext *ctxt = engine.rootContext(); + + // Register qml interface classes + QMLInterface::setup(ctxt); register_qml_types(&engine); KirigamiPlugin::getInstance().registerTypes(); #if defined(__APPLE__) && !defined(Q_OS_IOS) @@ -101,7 +105,6 @@ void run_ui() gpsSortModel->setDynamicSortFilter(true); gpsSortModel->setSortRole(GpsListModel::GpsWhenRole); gpsSortModel->sort(0, Qt::DescendingOrder); - QQmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("gpsModel", gpsSortModel); ctxt->setContextProperty("vendorList", vendorList); ctxt->setContextProperty("swipeModel", MobileModels::instance()->swipeModel()); @@ -195,13 +198,6 @@ void register_qml_types(QQmlEngine *engine) int rc; #ifdef SUBSURFACE_MOBILE - if (engine != NULL) { - QQmlContext *ct = engine->rootContext(); - - // Register qml interface classes - QMLInterface::setup(ct); - } - REGISTER_TYPE(QMLManager, "QMLManager"); REGISTER_TYPE(QMLProfile, "QMLProfile"); REGISTER_TYPE(DiveImportedModel, "DCImportModel"); -- cgit v1.2.3-70-g09d2