diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-10-16 17:21:55 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-03 09:00:11 +0000 |
commit | 164af37710e5721cbc7d79a0af20f2387181c59c (patch) | |
tree | 90949e65a650c6f10a968e83e83dbf7574c518b5 /src/qml/qml/v8 | |
parent | 051684f125bbc31bd882c4cd313c3482bcd145a0 (diff) |
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 <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/v8')
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 3fc7ac7748..72a3fe1537 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1013,8 +1013,13 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) if (!parentArg) V4THROW_ERROR("Qt.createQmlObject(): Missing parent object"); + QQmlTypeData *typeData = QQmlEnginePrivate::get(engine)->typeLoader.getType( + qml.toUtf8(), url, QQmlTypeLoader::Synchronous); + Q_ASSERT(typeData->isCompleteOrError()); QQmlComponent component(engine); - component.setData(qml.toUtf8(), url); + QQmlComponentPrivate *componentPrivate = QQmlComponentPrivate::get(&component); + componentPrivate->fromTypeData(typeData); + componentPrivate->progress = 1.0; if (component.isError()) { ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors())); |