diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-30 10:52:09 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-03-30 12:08:22 (GMT) |
commit | 725ed9f1c192e9c72ddfb2f34c28355ea2d0b769 (patch) | |
tree | 7c569156d67b8f80f7c870e05e5c0d4a52399207 | |
parent | b35988fe3299b2f76fb29507ca46298c2bef47df (diff) | |
download | Qt-725ed9f1c192e9c72ddfb2f34c28355ea2d0b769.zip Qt-725ed9f1c192e9c72ddfb2f34c28355ea2d0b769.tar.gz Qt-725ed9f1c192e9c72ddfb2f34c28355ea2d0b769.tar.bz2 |
Protect access to the call log with a mutex.
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 17 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 1 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 9924b1e..794c0ef 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -402,6 +402,7 @@ const char *xcb_protocol_request_codes[] = "Unknown" }; +#ifdef Q_XCB_DEBUG void QXcbConnection::log(const char *file, int line, int sequence) { CallInfo info; @@ -409,8 +410,10 @@ void QXcbConnection::log(const char *file, int line, int sequence) info.file = file; info.line = line; + QMutexLocker locker(&m_callLogMutex); m_callLog << info; } +#endif void QXcbConnection::run() { @@ -431,6 +434,7 @@ void QXcbConnection::run() int(error->major_code), xcb_protocol_request_codes[clamped_major_code], int(error->minor_code)); #ifdef Q_XCB_DEBUG + QMutexLocker locker(&m_callLogMutex); for (int i = 0; i < m_callLog.size(); ++i) { if (m_callLog.at(i).sequence == error->sequence) { printf("Caused by: %s:%d\n", qPrintable(m_callLog.at(i).file), m_callLog.at(i).line); @@ -442,11 +446,14 @@ void QXcbConnection::run() } #ifdef Q_XCB_DEBUG - int i = 0; - for (; i < m_callLog.size(); ++i) - if (m_callLog.at(i).sequence >= event->sequence) - break; - m_callLog.remove(0, i); + { + QMutexLocker locker(&m_callLogMutex); + int i = 0; + for (; i < m_callLog.size(); ++i) + if (m_callLog.at(i).sequence >= event->sequence) + break; + m_callLog.remove(0, i); + } #endif if (response_type == XCB_CLIENT_MESSAGE diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 0a7efd5..036670a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -304,6 +304,7 @@ private: int line; }; QVector<CallInfo> m_callLog; + QMutex m_callLogMutex; void log(const char *file, int line, int sequence); template <typename cookie_t> friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); |