From 164af37710e5721cbc7d79a0af20f2387181c59c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 16 Oct 2015 17:21:55 +0200 Subject: Load component synchronously in method_createQmlObject setData() is not guaranteed to synchronously load the type. In fact, most of the time, it doesn't. However, by adding a private Synchronous mode to QQmlTypeLoader we can prefetch the type synchronously and then inject it into the component. Task-number: QTBUG-45418 Change-Id: I640f12ad20c01b778b5bc41f43574d8aea504195 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypeloader_p.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/qml/qml/qqmltypeloader_p.h') diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index e7b4b8f95b..6433601ba8 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -215,7 +215,7 @@ class Q_AUTOTEST_EXPORT QQmlTypeLoader { Q_DECLARE_TR_FUNCTIONS(QQmlTypeLoader) public: - enum Mode { PreferSynchronous, Asynchronous }; + enum Mode { PreferSynchronous, Asynchronous, Synchronous }; class Q_QML_PRIVATE_EXPORT Blob : public QQmlDataBlob { @@ -283,7 +283,7 @@ public: QQmlImportDatabase *importDatabase(); QQmlTypeData *getType(const QUrl &url, Mode mode = PreferSynchronous); - QQmlTypeData *getType(const QByteArray &, const QUrl &url); + QQmlTypeData *getType(const QByteArray &, const QUrl &url, Mode mode = PreferSynchronous); QQmlScriptBlob *getScript(const QUrl &); QQmlQmldirData *getQmldir(const QUrl &); @@ -362,6 +362,13 @@ private: QmldirCache m_qmldirCache; ImportDirCache m_importDirCache; ImportQmlDirCache m_importQmlDirCache; + + template + void doLoad(const Loader &loader, QQmlDataBlob *blob, Mode mode); + + friend struct PlainLoader; + friend struct CachedLoader; + friend struct StaticLoader; }; class Q_AUTOTEST_EXPORT QQmlTypeData : public QQmlTypeLoader::Blob -- cgit v1.2.3