diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-09-28 10:32:00 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-09-29 20:32:42 +0200 |
commit | 04641454beb27f667062dbf79116729f159b0041 (patch) | |
tree | 2664d504dbb17f10792831f6e3b85e31640f3fba /src/corelib/kernel/qproperty.cpp | |
parent | 6b4e0c5803b4b8b4396791ba436d9692195993d6 (diff) |
Disable moving of QProperty
The semantics are not very intuitive, and it opens a can of worms
with regards to what should happen with observers that observe
that property.
Change-Id: I6fb00b7693904b968224cc87d098bbd0ea776ba3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 4fdf0d8100..3a2c8dcc0c 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -196,39 +196,6 @@ QMetaType QUntypedPropertyBinding::valueMetaType() const return d->valueMetaType(); } -QPropertyBindingData::QPropertyBindingData(QPropertyBindingData &&other, QUntypedPropertyData *propertyDataPtr) -{ - std::swap(d_ptr, other.d_ptr); - QPropertyBindingDataPointer d{this}; - d.setFirstObserver(nullptr); - if (auto binding = d.bindingPtr()) - binding->setProperty(propertyDataPtr); -} - -void QPropertyBindingData::moveAssign(QPropertyBindingData &&other, QUntypedPropertyData *propertyDataPtr) -{ - if (&other == this) - return; - - QPropertyBindingDataPointer d{this}; - auto observer = d.firstObserver(); - d.setFirstObserver(nullptr); - - if (auto binding = d.bindingPtr()) { - binding->unlinkAndDeref(); - d_ptr &= FlagMask; - } - - std::swap(d_ptr, other.d_ptr); - - if (auto binding = d.bindingPtr()) - binding->setProperty(propertyDataPtr); - - d.setFirstObserver(observer.ptr); - - // The caller will have to notify observers. -} - QPropertyBindingData::~QPropertyBindingData() { QPropertyBindingDataPointer d{this}; @@ -286,6 +253,12 @@ QUntypedPropertyBinding QPropertyBindingData::setBinding(const QUntypedPropertyB return QUntypedPropertyBinding(oldBinding.data()); } +QPropertyBindingData::QPropertyBindingData(QPropertyBindingData &&other) : d_ptr(std::exchange(other.d_ptr, 0)) +{ + QPropertyBindingDataPointer d{this}; + d.fixupFirstObserverAfterMove(); +} + QPropertyBindingPrivate *QPropertyBindingData::binding() const { QPropertyBindingDataPointer d{this}; @@ -694,12 +667,6 @@ QString QPropertyBindingError::description() const */ /*! - \fn template <typename T> QProperty<T> &QProperty<T>::operator=(QProperty &&other) - - Move-assigns \a other to this QProperty instance. -*/ - -/*! \fn template <typename T> QProperty<T>::QProperty(const QPropertyBinding<T> &binding) Constructs a property that is tied to the provided \a binding expression. The @@ -1395,7 +1362,7 @@ struct QBindingStoragePrivate if (index == newData->size) index = 0; } - new (pp + index) Pair{p->data, QPropertyBindingData(std::move(p->bindingData), p->data)}; + new (pp + index) Pair{p->data, QPropertyBindingData(std::move(p->bindingData))}; } } // data has been moved, no need to call destructors on old Pairs |