diff --git a/src/corelib/kernel/qpropertybinding.cpp b/src/corelib/kernel/qpropertybinding.cpp index 99d17757de0..63800c4f7dc 100644 --- a/src/corelib/kernel/qpropertybinding.cpp +++ b/src/corelib/kernel/qpropertybinding.cpp @@ -70,7 +70,7 @@ void QPropertyBindingPrivate::markDirtyAndNotifyObservers() if (firstObserver) firstObserver.notify(this, propertyDataPtr); if (hasStaticObserver) { - if (metaType == QMetaType::fromType()) { + if (isBool) { auto propertyPtr = reinterpret_cast(propertyDataPtr); bool oldValue = propertyPtr->extraBit(); staticObserverCallback(staticObserver, &oldValue); @@ -106,7 +106,7 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged() bool changed = false; if (hasStaticObserver && staticGuardCallback) { - if (metaType.id() == QMetaType::Bool) { + if (isBool) { auto propertyPtr = reinterpret_cast(propertyDataPtr); bool newValue = propertyPtr->extraBit(); changed = staticGuardCallback(metaType, &newValue, evaluationFunction, staticObserver); @@ -116,7 +116,7 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged() changed = staticGuardCallback(metaType, propertyDataPtr, evaluationFunction, staticObserver); } } else { - if (metaType.id() == QMetaType::Bool) { + if (isBool) { auto propertyPtr = reinterpret_cast(propertyDataPtr); bool newValue = propertyPtr->extraBit(); changed = evaluationFunction(metaType, &newValue); diff --git a/src/corelib/kernel/qpropertybinding_p.h b/src/corelib/kernel/qpropertybinding_p.h index 9a18ff90158..1aa2cd864cd 100644 --- a/src/corelib/kernel/qpropertybinding_p.h +++ b/src/corelib/kernel/qpropertybinding_p.h @@ -72,6 +72,7 @@ private: bool dirty = false; bool updating = false; bool hasStaticObserver = false; + bool isBool = false; QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction; @@ -99,7 +100,8 @@ public: QPropertyBindingPrivate(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction, const QPropertyBindingSourceLocation &location) - : evaluationFunction(std::move(evaluationFunction)) + : isBool(metaType.id() == QMetaType::Bool) + , evaluationFunction(std::move(evaluationFunction)) , inlineDependencyObservers() // Explicit initialization required because of union , location(location) , metaType(metaType)