diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-10-23 15:40:38 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-11-03 13:06:15 +0100 |
commit | a31dde22dbb37643dcabab12b2ac4e2f1d79f958 (patch) | |
tree | 1190c346233ec31f916ce76ff4d01ebefa6bb427 /src/corelib/kernel/qproperty_p.h | |
parent | c1c991c3190ec3e9ba5fae9c5ae40385686d289d (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_p.h')
-rw-r--r-- | src/corelib/kernel/qproperty_p.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 99a145c65a..9a0daaee3a 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -422,13 +422,15 @@ public: QBindingStorage *storage = qGetBindingStorage(owner()); auto *bd = storage->bindingData(this); // make sure we don't remove the binding if called from the bindingWrapper - if (bd && !inBindingWrapper(storage)) + const bool inWrapper = inBindingWrapper(storage); + if (bd && !inWrapper) bd->removeBinding(); if constexpr (QTypeTraits::has_operator_equal_v<T>) if (this->val == t) return; this->val = t; - notify(bd); + if (!inWrapper) + notify(bd); } QObjectCompatProperty &operator=(parameter_type newValue) |