summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2013-08-22 14:31:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-23 09:16:41 +0200
commitbd00b51c47f986dd2f8b7696b09f10f19321a99e (patch)
treef5aa8bb67a24476ddd840e69815690a2cbb60feb /src/plugins/platforms/xcb
parentd593d6955c149cf75a5f5796292b93ac9d636fee (diff)
XCB: Fix race with the event thread
The XCB backend runs a thread which gets events out of the XCB event queue and feeds it to the main thread via another queue. This queue is protected by a mutex. However, when the event thread exits, it cleans up after itself and frees all remaining entries in the queue. This code messed with the event queue without acquiring the needed mutex and left behind a list full of stale pointers. Fix this and protect the freeing with the correct mutex and clear the event queue afterwards. Change-Id: Ie49cf6241b76be86d8cebbc931f7226a3f6a14e5 Signed-off-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 01af23377e..2ce34ea8f2 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -989,8 +989,11 @@ void QXcbEventReader::run()
emit eventPending();
}
+ m_mutex.lock();
for (int i = 0; i < m_events.size(); ++i)
free(m_events.at(i));
+ m_events.clear();
+ m_mutex.unlock();
}
void QXcbEventReader::addEvent(xcb_generic_event_t *event)