diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2013-09-21 15:42:33 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-16 15:55:39 (GMT) |
commit | 27b7c8ac2f372232e0add9489086c91753033b20 (patch) | |
tree | db95f14d2afbf1b6cb09966943e9a7b85e7f0582 /src/corelib/thread | |
parent | cecceb0cdd87482124a73ecf537f3445d68be13e (diff) | |
download | Qt-27b7c8ac2f372232e0add9489086c91753033b20.zip Qt-27b7c8ac2f372232e0add9489086c91753033b20.tar.gz Qt-27b7c8ac2f372232e0add9489086c91753033b20.tar.bz2 |
QObject: use per-thread storage for qFlagLocation()
qFlagLocation() uses a global char* array to transport source location
information from the connect() side to the metaobject side. The size
of the array is 2 (two), which just about suffices for a single connect()
statement.
Obviously, if more than one thread makes a (_any_) connection at the same
time, the data is useless and, worse, there's a data race.
The non-reentrancy of qFlagLocations() cannot and need not be fixed,
but use a per-thread flagged_locations array in QThreadData so threads
don't disturb each other.
Task-number: QTBUG-3680
Change-Id: If1797c60751f551694def69afee6fbe295bbe2d2
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
(cherry picked from qtbase/c012ee2940bc087720b4aa0d257540921cf9a139)
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthread_p.h | 22 |
1 files changed, 22 insertions, 0 deletions
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 |