diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ee168dfc79..c72b8a761c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2602,11 +2602,29 @@ void QObject::deleteLater() Signals and slots *****************************************************************************/ +namespace { +// This class provides (per-thread) storage for qFlagLocation() +class FlaggedDebugSignatures +{ + static constexpr uint Count = 2; + + uint idx = 0; + const char *locations[Count] = {}; + +public: + void store(const char* method) + { locations[idx++ % Count] = method; } + + bool contains(const char *method) const + { return std::find(locations, locations + Count, method) != locations + Count; } +}; + +Q_THREAD_LOCAL_CONSTINIT static thread_local FlaggedDebugSignatures flaggedSignatures = {}; +} // unnamed namespace + const char *qFlagLocation(const char *method) { - QThreadData *currentThreadData = QThreadData::current(false); - if (currentThreadData != nullptr) - currentThreadData->flaggedSignatures.store(method); + flaggedSignatures.store(method); return method; } @@ -2618,7 +2636,7 @@ static int extract_code(const char *member) static const char *extract_location(const char *member) { - if (QThreadData::current()->flaggedSignatures.contains(member)) { + if (flaggedSignatures.contains(member)) { // signature includes location information after the first null-terminator const char *location = member + qstrlen(member) + 1; if (*location != '\0') diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 134c1577b2..6fdf785633 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -261,26 +261,6 @@ public: return canWait; } - // This class provides per-thread (by way of being a QThreadData - // member) storage for qFlagLocation() - class FlaggedDebugSignatures - { - static const uint Count = 2; - - uint idx; - const char *locations[Count]; - - public: - FlaggedDebugSignatures() : idx(0) - { std::fill_n(locations, Count, static_cast(nullptr)); } - - void store(const char* method) - { locations[idx++ % Count] = method; } - - bool contains(const char *method) const - { return std::find(locations, locations + Count, method) != locations + Count; } - }; - private: QAtomicInt _ref; @@ -294,7 +274,6 @@ public: QAtomicPointer threadId; QAtomicPointer eventDispatcher; QList tls; - FlaggedDebugSignatures flaggedSignatures; bool quitNow; bool canWait;