diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index a93fcdad031..70bed15c231 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -328,17 +328,18 @@ void QPropertyBindingData::evaluateIfDirty(const QUntypedPropertyData *property) binding->evaluateIfDirtyAndReturnTrueIfValueChanged(property); } -void QPropertyBindingData::removeBinding() +void QPropertyBindingData::removeBinding_helper() { QPropertyBindingDataPointer d{this}; - if (auto *existingBinding = d.bindingPtr()) { - auto observer = existingBinding->takeObservers(); - d_ptr = 0; - if (observer) - d.setObservers(observer.ptr); - existingBinding->unlinkAndDeref(); - } + auto *existingBinding = d.bindingPtr(); + Q_ASSERT(existingBinding); + + auto observer = existingBinding->takeObservers(); + d_ptr = 0; + if (observer) + d.setObservers(observer.ptr); + existingBinding->unlinkAndDeref(); } void QPropertyBindingData::registerWithCurrentlyEvaluatingBinding() const diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index 69e88b599f8..f4b81ea40b0 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -248,7 +248,11 @@ public: } void evaluateIfDirty(const QUntypedPropertyData *property) const; - void removeBinding(); + void removeBinding() + { + if (hasBinding()) + removeBinding_helper(); + } void registerWithCurrentlyEvaluatingBinding(QtPrivate::BindingEvaluationState *currentBinding) const { @@ -257,8 +261,10 @@ public: registerWithCurrentlyEvaluatingBinding_helper(currentBinding); } void registerWithCurrentlyEvaluatingBinding() const; - void registerWithCurrentlyEvaluatingBinding_helper(BindingEvaluationState *currentBinding) const; void notifyObservers(QUntypedPropertyData *propertyDataPtr) const; +private: + void registerWithCurrentlyEvaluatingBinding_helper(BindingEvaluationState *currentBinding) const; + void removeBinding_helper(); }; template