diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 20 | ||||
-rw-r--r-- | src/corelib/thread/qthread_p.h | 22 |
2 files changed, 28 insertions, 14 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index b355e33..aa1a00c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2159,14 +2159,9 @@ void QObject::deleteLater() *****************************************************************************/ -const int flagged_locations_count = 2; -static const char* flagged_locations[flagged_locations_count] = {0}; - const char *qFlagLocation(const char *method) { - static int idx = 0; - flagged_locations[idx] = method; - idx = (idx+1) % flagged_locations_count; + QThreadData::current()->flaggedSignatures.store(method); return method; } @@ -2178,14 +2173,11 @@ static int extract_code(const char *member) static const char * extract_location(const char *member) { - for (int i = 0; i < flagged_locations_count; ++i) { - if (member == flagged_locations[i]) { - // signature includes location information after the first null-terminator - const char *location = member + qstrlen(member) + 1; - if (*location != '\0') - return location; - return 0; - } + if (QThreadData::current()->flaggedSignatures.contains(member)) { + // signature includes location information after the first null-terminator + const char *location = member + qstrlen(member) + 1; + if (*location != '\0') + return location; } return 0; } diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index d404b53..7c9cfc4 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -229,6 +229,26 @@ 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<char*>(0)); } + + void store(const char* method) + { locations[idx++ % Count] = method; } + + bool contains(const char *method) const + { return std::find(locations, locations + Count, method) != locations + Count; } + }; + QThread *thread; Qt::HANDLE threadId; bool quitNow; @@ -243,6 +263,8 @@ public: # ifdef Q_OS_SYMBIAN RThread symbian_thread_handle; # endif + + FlaggedDebugSignatures flaggedSignatures; }; class QScopedLoopLevelCounter |