QProperty: Remove recursive notify logic

Grouped property updates have been ported to make use of the
non-recursive variant, and thus the last remaining user of recursive
notify() is gone.

Change-Id: I617db0dedc66555152a9b43514d9d8658d528f2c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Fabian Kosmale 2023-02-08 09:44:47 +01:00
parent 7a415a051a
commit d926490c80
2 changed files with 12 additions and 37 deletions

View File

@ -161,7 +161,7 @@ struct QPropertyDelayedNotifications
delayed->d_ptr = 0;
if (observer)
observer.notify<QPropertyObserverPointer::Notify::OnlyChangeHandlers>(delayed->propertyData);
observer.notify(delayed->propertyData);
}
};
@ -286,22 +286,6 @@ bool QPropertyBindingPrivate::evaluateRecursive(PendingBindingObserverList &bind
return evaluateRecursive_inline(bindingObservers, status);
}
void QPropertyBindingPrivate::notifyRecursive()
{
if (!pendingNotify)
return;
pendingNotify = false;
Q_ASSERT(!updating);
updating = true;
if (firstObserver) {
firstObserver.noSelfDependencies(this);
firstObserver.notify(propertyDataPtr);
}
if (hasStaticObserver)
staticObserverCallback(propertyDataPtr);
updating = false;
}
void QPropertyBindingPrivate::notifyNonRecursive(const PendingBindingObserverList &bindingObservers)
{
notifyNonRecursive();
@ -319,7 +303,7 @@ QPropertyBindingPrivate::NotificationState QPropertyBindingPrivate::notifyNonRec
updating = true;
if (firstObserver) {
firstObserver.noSelfDependencies(this);
firstObserver.notifyOnlyChangeHandler(propertyDataPtr);
firstObserver.notify(propertyDataPtr);
}
if (hasStaticObserver)
staticObserverCallback(propertyDataPtr);
@ -606,7 +590,7 @@ void QPropertyBindingData::notifyObservers(QUntypedPropertyData *propertyDataPtr
if (notifyObserver_helper(propertyDataPtr, storage, observer, bindingObservers) == Evaluated) {
// evaluateBindings() can trash the observers. We need to re-fetch here.
if (QPropertyObserverPointer observer = d.firstObserver())
observer.notifyOnlyChangeHandler(propertyDataPtr);
observer.notify(propertyDataPtr);
for (auto &&bindingObserver: bindingObservers)
bindingObserver.binding()->notifyNonRecursive();
}

View File

@ -144,9 +144,7 @@ struct QPropertyObserverPointer
enum class Notify {Everything, OnlyChangeHandlers};
template<Notify notifyPolicy = Notify::Everything>
void notify(QUntypedPropertyData *propertyDataPtr);
void notifyOnlyChangeHandler(QUntypedPropertyData *propertyDataPtr);
#ifndef QT_NO_DEBUG
void noSelfDependencies(QPropertyBindingPrivate *binding);
#else
@ -371,7 +369,6 @@ public:
bool Q_ALWAYS_INLINE evaluateRecursive_inline(PendingBindingObserverList &bindingObservers, QBindingStatus *status);
void notifyRecursive();
void notifyNonRecursive(const PendingBindingObserverList &bindingObservers);
enum NotificationState : bool { Delayed, Sent };
NotificationState notifyNonRecursive();
@ -632,7 +629,7 @@ public:
== QtPrivate::QPropertyBindingData::Evaluated) {
// evaluateBindings() can trash the observers. We need to re-fetch here.
if (QPropertyObserverPointer observer = d.firstObserver())
observer.notifyOnlyChangeHandler(this);
observer.notify(this);
for (auto&& bindingObserver: bindingObservers)
bindingObserver.binding()->notifyNonRecursive();
}
@ -834,7 +831,14 @@ inline bool QPropertyBindingPrivate::evaluateRecursive_inline(PendingBindingObse
return true;
}
template<QPropertyObserverPointer::Notify notifyPolicy>
/*!
\internal
Walks through the list of property observers, and calls any ChangeHandler
found there.
It doesn't do anything with bindings, which are only handled in
QPropertyBindingPrivate::evaluateRecursive.
*/
inline void QPropertyObserverPointer::notify(QUntypedPropertyData *propertyDataPtr)
{
auto observer = const_cast<QPropertyObserver*>(ptr);
@ -873,15 +877,7 @@ inline void QPropertyObserverPointer::notify(QUntypedPropertyData *propertyDataP
break;
}
case QPropertyObserver::ObserverNotifiesBinding:
{
if constexpr (notifyPolicy == Notify::Everything) {
auto bindingToNotify = observer->binding;
QPropertyObserverNodeProtector protector(observer);
bindingToNotify->notifyRecursive();
next = protector.next();
}
break;
}
case QPropertyObserver::ObserverIsPlaceholder:
// recursion is already properly handled somewhere else
break;
@ -895,11 +891,6 @@ inline void QPropertyObserverPointer::notify(QUntypedPropertyData *propertyDataP
}
}
inline void QPropertyObserverPointer::notifyOnlyChangeHandler(QUntypedPropertyData *propertyDataPtr)
{
notify<Notify::OnlyChangeHandlers>(propertyDataPtr);
}
inline QPropertyObserverNodeProtector::~QPropertyObserverNodeProtector()
{
QPropertyObserverPointer d{static_cast<QPropertyObserver *>(&m_placeHolder)};