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
This commit is contained in:
Aleix Pol 2014-11-19 11:52:21 +01:00
parent 7c65143e12
commit fe0d60cfca
2 changed files with 5 additions and 0 deletions

View File

@ -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()) {

View File

@ -96,6 +96,7 @@ Q_SIGNALS:
private Q_SLOTS:
void syncWallpaperPackage();
void executeAction(const QString &name);
void loadFinished();
private:
QString m_wallpaperPlugin;