aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2015-06-17 16:38:47 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-23 17:31:51 +0000
commit1b4f94c8fe0452cc053907fea2ad8be3930df8ce (patch)
tree3c65361cdeb08ce764979b8e35604f4a84c8f909 /src/qml/qml/qqmltypeloader.cpp
parentfcbefee383ccff2a6485acc120631123e30b41dd (diff)
Force completion of asynchronously loaded components.
[ChangeLog][QtQuick][QQmlComponent] Synchronously complete the loading of a Asynchronous QQmlComponent, if a PreferSynchronous QQmlComponent is created for the same url (given that this url does support synchronous loading). Change-Id: I3291d0569a69bac2aeb4815f1068a426ef2707ef Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index e860b8e0fa..408f17ffde 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1612,6 +1612,20 @@ QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode)
} else {
QQmlTypeLoader::load(typeData, mode);
}
+ } else if ((mode == PreferSynchronous) && QQmlFile::isSynchronous(url)) {
+ // this was started Asynchronous, but we need to force Synchronous
+ // completion now (if at all possible with this type of URL).
+
+ if (!m_thread->isThisThread()) {
+ // this only works when called directly from the UI thread, but not
+ // when recursively called on the QML thread via resolveTypes()
+
+ while (!typeData->isCompleteOrError()) {
+ unlock();
+ m_thread->waitForNextMessage();
+ lock();
+ }
+ }
}
typeData->addref();