summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qobject_p.h')
-rw-r--r--src/corelib/kernel/qobject_p.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index feafcaf323..1ebf8e7a07 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -374,7 +374,13 @@ public:
}
public:
ExtraData *extraData; // extra data set by the user
- QThreadData *threadData; // id of the thread that owns the object
+ QThreadData *getThreadData() const { return threadData.loadAcquire(); }
+ // This atomic requires acquire/release semantics in a few places,
+ // e.g. QObject::moveToThread must synchronize with QCoreApplication::postEvent,
+ // because postEvent is thread-safe.
+ // However, most of the code paths involving QObject are only reentrant and
+ // not thread-safe, so synchronization should not be necessary there.
+ QAtomicPointer<QThreadData> threadData; // id of the thread that owns the object
using ConnectionDataPointer = QExplicitlySharedDataPointer<ConnectionData>;
QAtomicPointer<ConnectionData> connections;