summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-10-23 15:40:38 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-11-03 13:06:15 +0100
commita31dde22dbb37643dcabab12b2ac4e2f1d79f958 (patch)
tree1190c346233ec31f916ce76ff4d01ebefa6bb427 /src/corelib/kernel/qproperty.cpp
parentc1c991c3190ec3e9ba5fae9c5ae40385686d289d (diff)
QProperty: Fix notification logic for eager properties
This ensurse that we do not do dobule notifications in setValue. Moerover we avoid needless notifications in markDirtyAndNotifyObservers when the value did not change. Lastly, if the value did actually change, we pass that information along to notify, so that we do not evaluate the eager property twice. Fixes a test-case which errorneously relied on the old behavior, and adds a new test which verifies that the fix works. Change-Id: I8ec6fa2fe8611565dfc603ceab3ba5f92999b26c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r--src/corelib/kernel/qproperty.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index 103c3d8482..147103aed9 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -110,12 +110,15 @@ void QPropertyBindingPrivate::markDirtyAndNotifyObservers()
eagerlyUpdating = true;
QScopeGuard guard([&](){eagerlyUpdating = false;});
+ bool knownIfChanged = false;
if (requiresEagerEvaluation()) {
// these are compat properties that we will need to evaluate eagerly
- evaluateIfDirtyAndReturnTrueIfValueChanged(propertyDataPtr);
+ if (!evaluateIfDirtyAndReturnTrueIfValueChanged(propertyDataPtr))
+ return;
+ knownIfChanged = true;
}
if (firstObserver)
- firstObserver.notify(this, propertyDataPtr);
+ firstObserver.notify(this, propertyDataPtr, knownIfChanged);
if (hasStaticObserver)
staticObserverCallback(propertyDataPtr);
}