diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2021-09-09 17:01:14 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-10 19:16:57 +0000 |
commit | e5e064b170bf694a24e0225f5cafea5829c9ad72 (patch) | |
tree | c6c05229176760c43d97af86045b16b40d48e9c1 | |
parent | 887f2d5451efffde1a9f80733ea435088e6c1888 (diff) |
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.
Task-number: QTBUG-96303
Change-Id: I4f8e67b49c1d6579228e22111105fb936f1f94db
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 248f0aad1c4f1c6e7e03ad265c2011390dca75ef)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/corelib/kernel/qproperty_p.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 55f0dc032c..6fcef939f7 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -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) + |