summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-28 10:32:00 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-09-29 20:32:42 +0200
commit04641454beb27f667062dbf79116729f159b0041 (patch)
tree2664d504dbb17f10792831f6e3b85e31640f3fba /src/corelib/kernel/qproperty_p.h
parent6b4e0c5803b4b8b4396791ba436d9692195993d6 (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_p.h')
-rw-r--r--src/corelib/kernel/qproperty_p.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h
index 614756a670..1bf308e8ea 100644
--- a/src/corelib/kernel/qproperty_p.h
+++ b/src/corelib/kernel/qproperty_p.h
@@ -81,6 +81,7 @@ struct Q_AUTOTEST_EXPORT QPropertyBindingDataPointer
observer->prev = reinterpret_cast<QPropertyObserver**>(&(ptr->d_ptr));
ptr->d_ptr = (reinterpret_cast<quintptr>(observer) & ~QtPrivate::QPropertyBindingData::FlagMask);
}
+ void fixupFirstObserverAfterMove() const;
void addObserver(QPropertyObserver *observer);
void setFirstObserver(QPropertyObserver *observer);
QPropertyObserverPointer firstObserver() const;
@@ -293,6 +294,17 @@ inline void QPropertyBindingDataPointer::setFirstObserver(QPropertyObserver *obs
ptr->d_ptr = reinterpret_cast<quintptr>(observer) | (ptr->d_ptr & QtPrivate::QPropertyBindingData::FlagMask);
}
+inline void QPropertyBindingDataPointer::fixupFirstObserverAfterMove() const
+{
+ // If QPropertyBindingData has been moved, and it has an observer
+ // we have to adjust the firstObesrver's prev pointer to point to
+ // the moved to QPropertyBindingData's d_ptr
+ if (ptr->d_ptr & QtPrivate::QPropertyBindingData::BindingBit)
+ return; // nothing to do if the observer is stored in the binding
+ if (auto observer = firstObserver())
+ observer.ptr->prev = reinterpret_cast<QPropertyObserver**>(&(ptr->d_ptr));
+}
+
inline QPropertyObserverPointer QPropertyBindingDataPointer::firstObserver() const
{
if (auto *binding = bindingPtr())