diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-09-24 17:23:55 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-09-28 09:11:16 +0200 |
commit | 1e883cf9b56376084f3329811aa91f4887ef6fcb (patch) | |
tree | c12a32fcc3cea219abd1bb152ef108f686a03eb1 /src/corelib/kernel/qproperty.cpp | |
parent | de52ad0a0f31654ff86e77fc4545335e9651d3f2 (diff) |
Prevent endless markDirtyAndNotifyObservers <-> notify loop
Before we had the option of eager evaluation, we were able to use the
dirty flag to detect whether we are recursing. However, eager properties
will lead to a evaluateIfDirtyAndReturnTrueIfValueChanged call, and that
in turn will clear the dirty flag.
Introduce a new member to detect that situation, and set the bindings
error state to BindingLoop if we detect that kind of loop.
Change-Id: If40b93221848bd9e9422502318d992fad95b0b74
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 72f74ac1e8..81871587e8 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -41,6 +41,7 @@ #include "qproperty_p.h" #include <qscopedvaluerollback.h> +#include <QScopeGuard> QT_BEGIN_NAMESPACE @@ -82,6 +83,13 @@ void QPropertyBindingPrivate::markDirtyAndNotifyObservers() if (dirty) return; dirty = true; + if (eagerlyUpdating) { + error = QPropertyBindingError(QPropertyBindingError::BindingLoop); + return; + } + + eagerlyUpdating = true; + QScopeGuard guard([&](){eagerlyUpdating = false;}); if (requiresEagerEvaluation()) { // these are compat properties that we will need to evaluate eagerly evaluateIfDirtyAndReturnTrueIfValueChanged(propertyDataPtr); |