diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-06-17 12:36:21 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-20 19:05:54 +0000 |
commit | ef7cda00dd64acca3a5fa48ee3cb129c781506f2 (patch) | |
tree | 1a0312028f4a6020c730d72fb8345d315ebe6a36 /src/corelib | |
parent | c38a40f7954f82d55d80f9689fdbafe9256528d4 (diff) |
Avoid misleading bindingStatus
Set it to nullptr on clear, and deal with possibly null bindingStatus.
Task-number: QTBUG-101177
Task-number: QTBUG-102403
Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 0bd287627508c61a7abfd6430d8c1243ea153081)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qbindingstorage.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qproperty_p.h | 4 |
4 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/kernel/qbindingstorage.h b/src/corelib/kernel/qbindingstorage.h index d8853fa265..8baf1b40e1 100644 --- a/src/corelib/kernel/qbindingstorage.h +++ b/src/corelib/kernel/qbindingstorage.h @@ -55,7 +55,7 @@ public: void registerDependency(const QUntypedPropertyData *data) const { - if (!bindingStatus->currentlyEvaluatingBinding) + if (!bindingStatus || !bindingStatus->currentlyEvaluatingBinding) return; registerDependency_helper(data); } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 05a881b63c..ebdc9e43f0 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1873,9 +1873,9 @@ void QObjectPrivate::moveToThread_helper() Q_Q(QObject); QEvent e(QEvent::ThreadChange); QCoreApplication::sendEvent(q, &e); + bindingStorage.clear(); for (int i = 0; i < children.size(); ++i) { QObject *child = children.at(i); - child->d_func()->bindingStorage.clear(); child->d_func()->moveToThread_helper(); } } diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 55e30c3069..482ed3bf35 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -2193,6 +2193,7 @@ void QBindingStorage::clear() { QBindingStoragePrivate(d).destroy(); d = nullptr; + bindingStatus = nullptr; } void QBindingStorage::registerDependency_helper(const QUntypedPropertyData *data) const diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 00e811f4c3..a569c172c5 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -442,7 +442,7 @@ class QObjectCompatProperty : public QPropertyData<T> } bool inBindingWrapper(const QBindingStorage *storage) const { - return storage->bindingStatus->currentCompatProperty + return storage->bindingStatus && storage->bindingStatus->currentCompatProperty && QtPrivate::isPropertyInBindingWrapper(this); } @@ -467,7 +467,7 @@ public: { const QBindingStorage *storage = qGetBindingStorage(owner()); // make sure we don't register this binding as a dependency to itself - if (storage->bindingStatus->currentlyEvaluatingBinding && !inBindingWrapper(storage)) + if (storage->bindingStatus && storage->bindingStatus->currentlyEvaluatingBinding && !inBindingWrapper(storage)) storage->registerDependency_helper(this); return this->val; } |