From bcf3f63d52b849d3989f21228f8fb0ce285c3cb2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Sun, 17 Oct 2021 11:43:35 +0200 Subject: [PATCH] QProperty: Eliminate further unnecessary TLS operations If we don't have a binding, we don't need to remove it. We can figure this out without TLS lookup. Pick-to: 6.2 Change-Id: I0cb20f2a68a119df7742631e307002e3813eac03 Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qproperty_p.h | 12 ++++++------ src/corelib/kernel/qpropertyprivate.h | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 0e1c87f13d4..111811134e7 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -456,8 +456,8 @@ public: { const QBindingStorage *storage = qGetBindingStorage(owner()); // make sure we don't register this binding as a dependency to itself - if (!inBindingWrapper(storage)) - storage->registerDependency(this); + if (storage->bindingStatus->currentlyEvaluatingBinding && !inBindingWrapper(storage)) + storage->registerDependency_helper(this); return this->val; } @@ -488,8 +488,8 @@ public: QBindingStorage *storage = qGetBindingStorage(owner()); if (auto *bd = storage->bindingData(this)) { // make sure we don't remove the binding if called from the bindingWrapper - if (!inBindingWrapper(storage)) - bd->removeBinding(); + if (bd->hasBinding() && !inBindingWrapper(storage)) + bd->removeBinding_helper(); } this->val = t; } @@ -539,8 +539,8 @@ public: QBindingStorage *storage = qGetBindingStorage(owner()); if (auto *bd = storage->bindingData(this)) { // make sure we don't remove the binding if called from the bindingWrapper - if (!inBindingWrapper(storage)) - bd->removeBinding(); + if (bd->hasBinding() && !inBindingWrapper(storage)) + bd->removeBinding_helper(); } } diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index b11d10cd52e..d3f384748a9 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -61,6 +61,9 @@ QT_BEGIN_NAMESPACE class QBindingStorage; +template +class QObjectCompatProperty; + namespace QtPrivate { // QPropertyBindingPrivatePtr operates on a RefCountingMixin solely so that we can inline // the constructor and copy constructor @@ -259,6 +262,10 @@ class Q_CORE_EXPORT QPropertyBindingData friend struct QT_PREPEND_NAMESPACE(QPropertyBindingDataPointer); friend class QT_PREPEND_NAMESPACE(QQmlPropertyBinding); friend struct QT_PREPEND_NAMESPACE(QPropertyDelayedNotifications); + + template + friend class QT_PREPEND_NAMESPACE(QObjectCompatProperty); + Q_DISABLE_COPY(QPropertyBindingData) public: QPropertyBindingData() = default;