diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-06-30 13:06:19 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-08-12 15:52:10 +0200 |
commit | f358188cbd2e47f82d7de3612181e628e1f1c05c (patch) | |
tree | 8befff9d83c4e96bab0b2e9af7727238b2e9be87 /src/qml/qml/qqmlobjectcreator.cpp | |
parent | 26884a4f34cfe6bc10daa19f2096aa49ed0a31f2 (diff) |
Do not set QQmlPropertyBinding until we reach finalize
If we install the binding eagerly, context properties cannot be resolved
yet, as the context object has not been created so far. This causes
issues with a QNotifiedProperty using a callback which accesses the
current value, and thus forcing the binding evaluation while the object
creation is still ongoing.
Change-Id: I3bf3def04cd044371cb757a1854a3224a9c669b8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 1018fbcb3b..1142618e2d 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -917,8 +917,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *bindingProper QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; qmlBinding = QQmlPropertyBinding::create(bindingProperty, runtimeFunction, _scopeObject, context, currentQmlContext()); } - void *argv[] = { &qmlBinding }; - _bindingTarget->qt_metacall(QMetaObject::SetQPropertyBinding, bindingProperty->coreIndex(), argv); + sharedState.data()->allQPropertyBindings.emplaceBack(_bindingTarget, bindingProperty->coreIndex(), qmlBinding); } else { // When writing bindings to grouped properties implemented as value types, // such as point.x: { someExpression; }, then the binding is installed on @@ -1419,6 +1418,15 @@ bool QQmlObjectCreator::finalize(QQmlInstantiationInterrupt &interrupt) return false; } + while (!sharedState->allQPropertyBindings.isEmpty()) { + auto& [target, index, qmlBinding] = sharedState->allQPropertyBindings.last(); + void *argv[] = { &qmlBinding }; + target->qt_metacall(QMetaObject::SetQPropertyBinding, index, argv); + sharedState->allQPropertyBindings.pop_back(); + if (watcher.hasRecursed() || interrupt.shouldInterrupt()) + return false; + } + if (QQmlVME::componentCompleteEnabled()) { // the qml designer does the component complete later while (!sharedState->allParserStatusCallbacks.isEmpty()) { QQmlObjectCompletionProfiler profiler(&sharedState->profiler); |