From 725ed9f1c192e9c72ddfb2f34c28355ea2d0b769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 30 Mar 2011 12:52:09 +0200 Subject: Protect access to the call log with a mutex. --- src/plugins/platforms/xcb/qxcbconnection.cpp | 17 ++++++++++++----- 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 m_callLog; + QMutex m_callLogMutex; void log(const char *file, int line, int sequence); template friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); -- cgit v0.12