From 0d284ae2d62707e6c35c8d97ca73e974d35c4167 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 24 Apr 2012 14:39:38 +0200 Subject: Debugger: Fix race conditions in block mode Using waitForMessage() in the constructor after registerService() is _not_ safe: You might get the first message already after the registerService() and before the waitForMessage() call. Instead, use QMutex/QWaitCondition to block the initialization. Also make the use of the block mode explicit, since the service might already be enabled also for non-blocking modes ... Change-Id: I387bfe0627c80e2029acff71f86d12cd9ab58de1 Reviewed-by: Kai Koehne --- src/qml/debugger/qqmlprofilerservice_p.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/qml/debugger/qqmlprofilerservice_p.h') diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h index 208fde5a75..eeaf871ab4 100644 --- a/src/qml/debugger/qqmlprofilerservice_p.h +++ b/src/qml/debugger/qqmlprofilerservice_p.h @@ -61,6 +61,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -164,9 +165,10 @@ private: private: QElapsedTimer m_timer; bool m_enabled; - bool m_messageReceived; QVector m_data; - QMutex m_mutex; + QMutex m_dataMutex; + QMutex m_initializeMutex; + QWaitCondition m_initializeCondition; static QQmlProfilerService *instance; -- cgit v1.2.3