summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-08-21 17:52:22 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-02 22:44:28 +0200
commitb788c64dc3a5e40ac410b9bd2c79f6f2d0963737 (patch)
treee1c0996448bfbd38242d3a53ff133e0fdd93a81c /src/corelib/kernel/qproperty.cpp
parent6778b247a8c20adfb3f4e3094077baae43f3e65c (diff)
Cleanup QBindingPrivate
Simplify the data structure. We only need one pointer for either the static callback or a bindingWrapper, so don't share it with the dependency observer array. Also ensure we reset the propertyDataPtr and clear the observers when the binding gets removed from a property. Change-Id: I4c1e7ec7823c3ef12c63d6f758b757e7bac60cae Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r--src/corelib/kernel/qproperty.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index 7cacd3f873..3c1d682b7c 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -68,8 +68,6 @@ QPropertyBindingPrivate::~QPropertyBindingPrivate()
{
if (firstObserver)
firstObserver.unlink();
- if (!hasStaticObserver)
- inlineDependencyObservers.~ObserverArray(); // Explicit because of union.
}
void QPropertyBindingPrivate::unlinkAndDeref()
@@ -115,8 +113,8 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged()
bool changed = false;
- if (hasStaticObserver && staticGuardCallback) {
- changed = staticGuardCallback(metaType, propertyDataPtr, evaluationFunction);
+ if (hasBindingWrapper) {
+ changed = staticBindingWrapper(metaType, propertyDataPtr, evaluationFunction);
} else {
changed = evaluationFunction(metaType, propertyDataPtr);
}
@@ -231,7 +229,7 @@ QPropertyBindingData::~QPropertyBindingData()
QUntypedPropertyBinding QPropertyBindingData::setBinding(const QUntypedPropertyBinding &binding,
QUntypedPropertyData *propertyDataPtr,
QPropertyObserverCallback staticObserverCallback,
- QtPrivate::QPropertyGuardFunction guardCallback)
+ QtPrivate::QPropertyBindingWrapper guardCallback)
{
QPropertyBindingPrivatePtr oldBinding;
QPropertyBindingPrivatePtr newBinding = binding.d;
@@ -265,6 +263,9 @@ QUntypedPropertyBinding QPropertyBindingData::setBinding(const QUntypedPropertyB
d_ptr &= ~QPropertyBindingData::BindingBit;
}
+ if (oldBinding)
+ oldBinding->detachFromProperty();
+
return QUntypedPropertyBinding(oldBinding.data());
}