QProperty: Refresh the observers after evaluating bindings

Evaluating bindings may actually break bindings, and remove observers.
Therefore, we need to re-fetch for notifying afterwards.

Fixes: QTBUG-94220
Change-Id: I96a78a825f983f58f1a574bf886e643f54453fdc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2021-06-04 17:11:14 +02:00
parent 0078a78254
commit d7f7d84365

View File

@ -546,16 +546,21 @@ void QPropertyBindingData::notifyObservers(QUntypedPropertyData *propertyDataPtr
if (isNotificationDelayed())
return;
QPropertyBindingDataPointer d{this};
QPropertyObserverPointer observer = d.firstObserver();
if (!observer)
return;
auto *delay = groupUpdateData;
if (delay) {
delay->addProperty(this, propertyDataPtr);
if (QPropertyObserverPointer observer = d.firstObserver()) {
auto *delay = groupUpdateData;
if (delay) {
delay->addProperty(this, propertyDataPtr);
return;
}
observer.evaluateBindings();
} else {
return;
}
observer.evaluateBindings();
observer.notify(propertyDataPtr);
// evaluateBindings() can trash the observers. We need to re-fetch here.
if (QPropertyObserverPointer observer = d.firstObserver())
observer.notify(propertyDataPtr);
}
int QPropertyBindingDataPointer::observerCount() const