From 331c106bdbf12c6925c2c40f3813b71c65caf9a2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 Aug 2020 11:33:13 +0200 Subject: [PATCH] Remove the special handling of QProperty Since we will be storing property data differently in most cases, having this special case would create too many additional complications. Change-Id: I27042b0730559bb375d8e3c07324398403a9885d Reviewed-by: Volker Hilsheimer Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qproperty.cpp | 31 +++---------------- src/corelib/kernel/qproperty_p.h | 4 +-- src/corelib/kernel/qpropertyprivate.h | 22 ------------- .../kernel/qproperty/tst_qproperty.cpp | 2 -- 4 files changed, 5 insertions(+), 54 deletions(-) diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index a0cdda4200..bd623bed18 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -86,15 +86,8 @@ void QPropertyBindingPrivate::markDirtyAndNotifyObservers() dirty = true; if (firstObserver) firstObserver.notify(this, propertyDataPtr); - if (hasStaticObserver) { - if (isBool) { - auto propertyPtr = reinterpret_cast(propertyDataPtr); - bool oldValue = propertyPtr->extraBit(); - staticObserverCallback(staticObserver, &oldValue); - } else { - staticObserverCallback(staticObserver, propertyDataPtr); - } - } + if (hasStaticObserver) + staticObserverCallback(staticObserver, propertyDataPtr); } bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged() @@ -123,25 +116,9 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged() bool changed = false; if (hasStaticObserver && staticGuardCallback) { - if (isBool) { - auto propertyPtr = reinterpret_cast(propertyDataPtr); - bool newValue = propertyPtr->extraBit(); - changed = staticGuardCallback(metaType, &newValue, evaluationFunction, staticObserver); - if (changed && !error.hasError()) - propertyPtr->setExtraBit(newValue); - } else { - changed = staticGuardCallback(metaType, propertyDataPtr, evaluationFunction, staticObserver); - } + changed = staticGuardCallback(metaType, propertyDataPtr, evaluationFunction, staticObserver); } else { - if (isBool) { - auto propertyPtr = reinterpret_cast(propertyDataPtr); - bool newValue = propertyPtr->extraBit(); - changed = evaluationFunction(metaType, &newValue); - if (changed && !error.hasError()) - propertyPtr->setExtraBit(newValue); - } else { - changed = evaluationFunction(metaType, propertyDataPtr); - } + changed = evaluationFunction(metaType, propertyDataPtr); } dirty = false; diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 9c43c23959..4cb55f8b47 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -140,7 +140,6 @@ private: bool dirty = false; bool updating = false; bool hasStaticObserver = false; - bool isBool = false; QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction; @@ -168,8 +167,7 @@ public: QPropertyBindingPrivate(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction, const QPropertyBindingSourceLocation &location) - : isBool(metaType.id() == QMetaType::Bool) - , evaluationFunction(std::move(evaluationFunction)) + : evaluationFunction(std::move(evaluationFunction)) , inlineDependencyObservers() // Explicit initialization required because of union , location(location) , metaType(metaType) diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index 4d8a457e32..fe6895d953 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -157,28 +157,6 @@ public: } }; -template<> -struct QPropertyValueStorage -{ - QPropertyBase priv; - - QPropertyValueStorage() = default; - Q_DISABLE_COPY(QPropertyValueStorage) - explicit QPropertyValueStorage(bool initialValue) { priv.setExtraBit(initialValue); } - QPropertyValueStorage &operator=(bool newValue) { priv.setExtraBit(newValue); return *this; } - QPropertyValueStorage(QPropertyValueStorage &&other) : priv(std::move(other.priv), this) {} - QPropertyValueStorage &operator=(QPropertyValueStorage &&other) { priv.moveAssign(std::move(other.priv), this); return *this; } - - bool getValue() const { return priv.extraBit(); } - bool setValueAndReturnTrueIfChanged(bool v) - { - if (v == priv.extraBit()) - return false; - priv.setExtraBit(v); - return true; - } -}; - template class QTagPreservingPointerToPointer { diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 20565080ff..ebb8980d61 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -259,8 +259,6 @@ void tst_QProperty::propertyArrays() void tst_QProperty::boolProperty() { - static_assert(sizeof(QProperty) == sizeof(void*), "Size of QProperty specialization must not exceed size of pointer"); - QProperty first(true); QProperty second(false); QProperty all;