From 5b81c80b464ac27b70546ad5ae8cc09e131d30c5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 18 Aug 2020 22:33:41 +0200 Subject: Add QObjectCompatProperty Add a compatibility property class that makes porting to the new property system as simple as possible. Binding evaluation for those compat properties is eager, as we do not control possible side effects of the code in the existing setters. Change-Id: Ic56347abb49e40631ec73e88c6d40d4bdb05ca29 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qpropertyprivate.h | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) (limited to 'src/corelib/kernel/qpropertyprivate.h') diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index 15e54e9ba8..dd344c209a 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -76,10 +76,8 @@ namespace QtPrivate { // writes binding result into dataPtr using QPropertyBindingFunction = std::function; - -using QPropertyBindingWrapper = bool(*)(QMetaType, QUntypedPropertyData *dataPtr, - QPropertyBindingFunction); using QPropertyObserverCallback = void (*)(QUntypedPropertyData *); +using QPropertyBindingWrapper = bool(*)(QMetaType, QUntypedPropertyData *dataPtr, QPropertyBindingFunction); class Q_CORE_EXPORT QPropertyBindingData { @@ -101,7 +99,8 @@ public: QUntypedPropertyBinding setBinding(const QUntypedPropertyBinding &newBinding, QUntypedPropertyData *propertyDataPtr, QPropertyObserverCallback staticObserverCallback = nullptr, - QPropertyBindingWrapper guardCallback = nullptr); + QPropertyBindingWrapper bindingWrapper = nullptr); + QPropertyBindingPrivate *binding() const; void evaluateIfDirty(const QUntypedPropertyData *property) const; @@ -188,30 +187,6 @@ namespace detail { } } -// type erased guard functions, casts its arguments to the correct types -template> -struct QPropertyGuardFunctionHelper -{ - static constexpr QPropertyBindingWrapper guard = nullptr; -}; -template -struct QPropertyGuardFunctionHelper -{ - static auto guard(QMetaType metaType, QUntypedPropertyData *dataPtr, - QPropertyBindingFunction eval, void *owner) -> bool - { - T t = T(); - eval(metaType, &t); - if (!(static_cast(owner)->*Guard)(t)) - return false; - T *data = static_cast(dataPtr); - if (*data == t) - return false; - *data = std::move(t); - return true; - }; -}; - } // namespace QtPrivate QT_END_NAMESPACE -- cgit v1.2.3