summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-01-12 10:47:19 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-01-13 18:47:23 +0000
commit3f32dcd1ddcbe04c77ccd83e2eaa566d7212e732 (patch)
tree1b9c9243947ca76ceeed0b911dca1537e33a0976
parentd83dbc3db2f305e745cd75a9fd9c97128eaac42f (diff)
Allow reading QObject::objectName from other threads again
The new binding system made it impossible to read from non-owning threads, but we have code that did so with external locking. This patch makes it safe again, assuming all reads and writes are locked. This is left intentionally undocumented. Pick-to: 6.3 6.2 Task-number: QTBUG-99775 Change-Id: I845afa5d545ca0ac762ac369181b1497dac52195 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/kernel/qobject.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 523e952579..eac5f33501 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1245,6 +1245,10 @@ QObjectPrivate::Connection::~Connection()
QString QObject::objectName() const
{
Q_D(const QObject);
+#if QT_CONFIG(thread)
+ if (QThread::currentThreadId() != d->threadData.loadRelaxed()->threadId.loadRelaxed()) // Unsafe code path
+ return d->extraData ? d->extraData->objectName.valueBypassingBindings() : QString();
+#endif
if (!d->extraData && QtPrivate::isAnyBindingEvaluating()) {
QObjectPrivate *dd = const_cast<QObjectPrivate *>(d);
// extraData is mutable, so this should be safe