Skip to content

Commit

Permalink
Make it possible to take bindings from properties without private hea…
Browse files Browse the repository at this point in the history
…ders

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 <[email protected]>
  • Loading branch information
tronical committed Apr 17, 2020
1 parent 6ce4c7d commit 4857f0e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/corelib/kernel/qproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/kernel/qproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Q_CORE_EXPORT QUntypedPropertyBinding

QMetaType valueMetaType() const;

explicit QUntypedPropertyBinding(const QPropertyBindingPrivatePtr &priv);
explicit QUntypedPropertyBinding(QPropertyBindingPrivate *priv);
private:
friend class QtPrivate::QPropertyBase;
friend class QPropertyBindingPrivate;
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/kernel/qpropertybinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ QUntypedPropertyBinding &QUntypedPropertyBinding::operator=(QUntypedPropertyBind
return *this;
}

QUntypedPropertyBinding::QUntypedPropertyBinding(const QPropertyBindingPrivatePtr &priv)
QUntypedPropertyBinding::QUntypedPropertyBinding(QPropertyBindingPrivate *priv)
: d(priv)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/kernel/qpropertyprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Q_CORE_EXPORT QPropertyBase
bool hasBinding() const { return d_ptr & BindingBit; }

QUntypedPropertyBinding setBinding(const QUntypedPropertyBinding &newBinding, void *propertyDataPtr);
QPropertyBindingPrivatePtr binding();
QPropertyBindingPrivate *binding();

void evaluateIfDirty();
void removeBinding();
Expand Down

0 comments on commit 4857f0e

Please sign in to comment.