diff options
Diffstat (limited to 'src/corelib/kernel/qproperty_p.h')
-rw-r--r-- | src/corelib/kernel/qproperty_p.h | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 67ce9a74f2..e88547569e 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -134,16 +134,26 @@ struct BindingEvaluationState BindingEvaluationState **currentState = nullptr; }; -struct CurrentCompatProperty +/*! + * \internal + * CompatPropertySafePoint needs to be constructed before the setter of + * a QObjectCompatProperty runs. It prevents spurious binding dependencies + * caused by reads of properties inside the compat property setter. + * Moreover, it ensures that we don't destroy bindings when using operator= + */ +struct CompatPropertySafePoint { - Q_CORE_EXPORT CurrentCompatProperty(QBindingStatus *status, QUntypedPropertyData *property); - ~CurrentCompatProperty() + Q_CORE_EXPORT CompatPropertySafePoint(QBindingStatus *status, QUntypedPropertyData *property); + ~CompatPropertySafePoint() { *currentState = previousState; + *currentlyEvaluatingBindingList = bindingState; } QUntypedPropertyData *property; - CurrentCompatProperty *previousState = nullptr; - CurrentCompatProperty **currentState = nullptr; + CompatPropertySafePoint *previousState = nullptr; + CompatPropertySafePoint **currentState = nullptr; + QtPrivate::BindingEvaluationState **currentlyEvaluatingBindingList = nullptr; + QtPrivate::BindingEvaluationState *bindingState = nullptr; }; } @@ -360,7 +370,7 @@ class QObjectCompatProperty : public QPropertyData<T> return false; // ensure value and setValue know we're currently evaluating our binding QBindingStorage *storage = qGetBindingStorage(thisData->owner()); - QtPrivate::CurrentCompatProperty guardThis(storage->bindingStatus, thisData); + QtPrivate::CompatPropertySafePoint guardThis(storage->bindingStatus, thisData); (thisData->owner()->*Setter)(copy.valueBypassingBindings()); return true; } |