From 4857f0ebd7f4ea422f7a5dc721f0204390adddbb Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 16 Apr 2020 08:30:18 +0200 Subject: [PATCH] Make it possible to take bindings from properties without private headers Passing the QExplicitlySharedDataPointer by reference may lead compilers to wanting to have visibility to the destructor of the contained type (QPropertyBindingPrivate), which is not public. Fortunately QExplicitlySharedDataPointer is safe to use with raw pointers and those can be safely forward declared. Change-Id: I131ab6363eaee10b6dce196fb2c769e09a5c9557 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qproperty.cpp | 10 +++++----- src/corelib/kernel/qproperty.h | 2 +- src/corelib/kernel/qpropertybinding.cpp | 2 +- src/corelib/kernel/qpropertyprivate.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 0e51226b34..e249dcfb44 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -102,7 +102,7 @@ QUntypedPropertyBinding QPropertyBase::setBinding(const QUntypedPropertyBinding if (auto *existingBinding = d.bindingPtr()) { if (existingBinding == newBinding.data()) - return QUntypedPropertyBinding(oldBinding); + return QUntypedPropertyBinding(oldBinding.data()); oldBinding = QPropertyBindingPrivatePtr(existingBinding); oldBinding->unlinkAndDeref(); d_ptr &= FlagMask; @@ -119,15 +119,15 @@ QUntypedPropertyBinding QPropertyBase::setBinding(const QUntypedPropertyBinding d_ptr &= ~BindingBit; } - return QUntypedPropertyBinding(oldBinding); + return QUntypedPropertyBinding(oldBinding.data()); } -QPropertyBindingPrivatePtr QPropertyBase::binding() +QPropertyBindingPrivate *QPropertyBase::binding() { QPropertyBasePointer d{this}; if (auto binding = d.bindingPtr()) - return QPropertyBindingPrivatePtr(binding); - return QPropertyBindingPrivatePtr(); + return binding; + return nullptr; } QPropertyBindingPrivate *QPropertyBasePointer::bindingPtr() const diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 609bb85221..8f050327d5 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -137,7 +137,7 @@ public: QMetaType valueMetaType() const; - explicit QUntypedPropertyBinding(const QPropertyBindingPrivatePtr &priv); + explicit QUntypedPropertyBinding(QPropertyBindingPrivate *priv); private: friend class QtPrivate::QPropertyBase; friend class QPropertyBindingPrivate; diff --git a/src/corelib/kernel/qpropertybinding.cpp b/src/corelib/kernel/qpropertybinding.cpp index 8fdf770d18..358977e63e 100644 --- a/src/corelib/kernel/qpropertybinding.cpp +++ b/src/corelib/kernel/qpropertybinding.cpp @@ -134,7 +134,7 @@ QUntypedPropertyBinding &QUntypedPropertyBinding::operator=(QUntypedPropertyBind return *this; } -QUntypedPropertyBinding::QUntypedPropertyBinding(const QPropertyBindingPrivatePtr &priv) +QUntypedPropertyBinding::QUntypedPropertyBinding(QPropertyBindingPrivate *priv) : d(priv) { } diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index 1329ec6682..4b0b09d9db 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -83,7 +83,7 @@ public: bool hasBinding() const { return d_ptr & BindingBit; } QUntypedPropertyBinding setBinding(const QUntypedPropertyBinding &newBinding, void *propertyDataPtr); - QPropertyBindingPrivatePtr binding(); + QPropertyBindingPrivate *binding(); void evaluateIfDirty(); void removeBinding();