Fix binding guard in property evaluation
The comment for keepAlive means that it should be destroyed after the updateGuard goes out of scope and restores its value. In this case keepAlive should be actually created *before* updateGuard, not after it. Pick-to: 6.2 6.2.0 Task-number: QTBUG-96303 Change-Id: I4f8e67b49c1d6579228e22111105fb936f1f94db Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
b5a23e88be
commit
248f0aad1c
@ -707,18 +707,18 @@ inline void QPropertyBindingPrivate::evaluateRecursive_inline(QBindingStatus *st
|
||||
return;
|
||||
}
|
||||
|
||||
QScopedValueRollback<bool> updateGuard(updating, true);
|
||||
|
||||
/*
|
||||
* Evaluating the binding might lead to the binding being broken. This can
|
||||
* cause ref to reach zero at the end of the function. However, the
|
||||
* updateGuard's destructor will then still trigger, trying to set the
|
||||
* updating bool to its old value
|
||||
* To prevent this, we create a QPropertyBindingPrivatePtr which ensures
|
||||
* that the object is still alive when updateGuard's dtor runs.
|
||||
*/
|
||||
* Evaluating the binding might lead to the binding being broken. This can
|
||||
* cause ref to reach zero at the end of the function. However, the
|
||||
* updateGuard's destructor will then still trigger, trying to set the
|
||||
* updating bool to its old value
|
||||
* To prevent this, we create a QPropertyBindingPrivatePtr which ensures
|
||||
* that the object is still alive when updateGuard's dtor runs.
|
||||
*/
|
||||
QPropertyBindingPrivatePtr keepAlive {this};
|
||||
|
||||
QScopedValueRollback<bool> updateGuard(updating, true);
|
||||
|
||||
QtPrivate::BindingEvaluationState evaluationFrame(this, status);
|
||||
|
||||
auto bindingFunctor = reinterpret_cast<std::byte *>(this) +
|
||||
|
Loading…
Reference in New Issue
Block a user