From fe0d60cfcaf21d233597cca1da7f2d1fa1e58a54 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 19 Nov 2014 11:52:21 +0100 Subject: [PATCH] Make WallpaperInterface use the suggested async object loading API Just asks QmlObject to create an object and waits for QmlObject::finished signal to acquire it. REVIEW: 121148 --- src/scriptengines/qml/plasmoid/wallpaperinterface.cpp | 4 ++++ src/scriptengines/qml/plasmoid/wallpaperinterface.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp index 36e34b58a..99ca33629 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -124,6 +124,7 @@ void WallpaperInterface::syncWallpaperPackage() m_qmlObject = new KDeclarative::QmlObject(this); s_rootObjects[m_qmlObject->engine()] = this; m_qmlObject->setInitializationDelayed(true); + connect(m_qmlObject, &KDeclarative::QmlObject::finished, this, &WallpaperInterface::loadFinished); } m_actions->clear(); @@ -145,7 +146,10 @@ void WallpaperInterface::syncWallpaperPackage() m_qmlObject->setSource(QUrl::fromLocalFile(m_pkg.filePath("mainscript"))); m_qmlObject->engine()->rootContext()->setContextProperty("wallpaper", this); m_qmlObject->completeInitialization(); +} +void WallpaperInterface::loadFinished() +{ if (m_qmlObject->mainComponent() && m_qmlObject->rootObject() && !m_qmlObject->mainComponent()->isError()) { diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.h b/src/scriptengines/qml/plasmoid/wallpaperinterface.h index 20c811fea..622e7585e 100644 --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.h +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.h @@ -96,6 +96,7 @@ Q_SIGNALS: private Q_SLOTS: void syncWallpaperPackage(); void executeAction(const QString &name); + void loadFinished(); private: QString m_wallpaperPlugin;