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 <fabian.kosmale@qt.io>
This commit is contained in:
Simon Hausmann 2020-04-16 08:30:18 +02:00
parent 6ce4c7d002
commit 4857f0ebd7
4 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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;

View File

@ -134,7 +134,7 @@ QUntypedPropertyBinding &QUntypedPropertyBinding::operator=(QUntypedPropertyBind
return *this;
}
QUntypedPropertyBinding::QUntypedPropertyBinding(const QPropertyBindingPrivatePtr &priv)
QUntypedPropertyBinding::QUntypedPropertyBinding(QPropertyBindingPrivate *priv)
: d(priv)
{
}

View File

@ -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();