summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-12-08 16:03:36 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-09 14:39:44 +0000
commit0292acf06df4444086586b951dd1567506e07fa0 (patch)
tree870aa71f12ac27624188e8af1689800ec26a5938 /src/corelib/kernel/qproperty.cpp
parent2f60a68ca411d79b9a43a0a82dc25a88aabc6bff (diff)
QProperty: Handle eager binding calling setBinding
When an eager binding triggers a setBinding call, we end up with a special kind of binding loop: setBinding() -> evaluate -> notifyObserver ^ | | / ---------------------------- We now catch set condition, and set the binding status to BindingLoop (with a distinct description). Task-number: QTBUG-87153 Task-number: QTBUG-87733 Change-Id: I9f9915797d82eab820fc279baceaf89d7e5a3f4a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit ddc585b7c773786045f3658d7da5425ed2f2f786) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r--src/corelib/kernel/qproperty.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index d2fd572b69..715e421295 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -246,6 +246,10 @@ QUntypedPropertyBinding QPropertyBindingData::setBinding(const QUntypedPropertyB
if (auto *existingBinding = d.bindingPtr()) {
if (existingBinding == newBinding.data())
return QUntypedPropertyBinding(static_cast<QPropertyBindingPrivate *>(oldBinding.data()));
+ if (existingBinding->isEagerlyUpdating()) {
+ existingBinding->setError({QPropertyBindingError::BindingLoop, QStringLiteral("Binding set during binding evaluation!")});
+ return QUntypedPropertyBinding(static_cast<QPropertyBindingPrivate *>(oldBinding.data()));
+ }
oldBinding = QPropertyBindingPrivatePtr(existingBinding);
observer = static_cast<QPropertyBindingPrivate *>(oldBinding.data())->takeObservers();
static_cast<QPropertyBindingPrivate *>(oldBinding.data())->unlinkAndDeref();
@@ -265,9 +269,11 @@ QUntypedPropertyBinding QPropertyBindingData::setBinding(const QUntypedPropertyB
newBindingRaw->prependObserver(observer);
newBindingRaw->setStaticObserver(staticObserverCallback, guardCallback);
if (newBindingRaw->requiresEagerEvaluation()) {
+ newBindingRaw->setEagerlyUpdating(true);
auto changed = newBindingRaw->evaluateIfDirtyAndReturnTrueIfValueChanged(propertyDataPtr);
if (changed)
observer.notify(newBindingRaw, propertyDataPtr, /*alreadyKnownToHaveChanged=*/true);
+ newBindingRaw->setEagerlyUpdating(false);
}
} else if (observer) {
d.setObservers(observer.ptr);