Debugger: Add asserts for right usage of threads
authorKai Koehne <kai.koehne@nokia.com>
Wed, 11 Apr 2012 14:27:14 +0000 (16:27 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 24 Apr 2012 13:58:25 +0000 (15:58 +0200)
Change-Id: I7c377863eb42e693aa4022af33a83098547e0d58
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
src/qml/debugger/qqmldebugserver.cpp

index 3b18f75..25cd18b 100644 (file)
@@ -370,6 +370,9 @@ QQmlDebugServer::~QQmlDebugServer()
 
 void QQmlDebugServer::receiveMessage(const QByteArray &message)
 {
+    // to be executed in debugger thread
+    Q_ASSERT(QThread::currentThread() == thread());
+
     Q_D(QQmlDebugServer);
 
     QDataStream in(message);
@@ -512,6 +515,10 @@ QStringList QQmlDebugServer::serviceNames() const
 bool QQmlDebugServer::addService(QQmlDebugService *service)
 {
     Q_D(QQmlDebugServer);
+
+    // to be executed in GUI thread
+    Q_ASSERT(QThread::currentThread() == QCoreApplication::instance()->thread());
+
     {
         QWriteLocker(&d->pluginsLock);
         if (!service || d->plugins.contains(service->name()))
@@ -532,6 +539,10 @@ bool QQmlDebugServer::addService(QQmlDebugService *service)
 bool QQmlDebugServer::removeService(QQmlDebugService *service)
 {
     Q_D(QQmlDebugServer);
+
+    // to be executed in GUI thread
+    Q_ASSERT(QThread::currentThread() == QCoreApplication::instance()->thread());
+
     {
         QWriteLocker(&d->pluginsLock);
         QQmlDebugService::State newState = QQmlDebugService::NotConnected;
@@ -568,6 +579,9 @@ void QQmlDebugServer::sendMessages(QQmlDebugService *service,
 
 bool QQmlDebugServer::waitForMessage(QQmlDebugService *service)
 {
+    // to be executed in GUI thread
+    Q_ASSERT(QThread::currentThread() == QCoreApplication::instance()->thread());
+
     Q_D(QQmlDebugServer);
     QReadLocker(&d->pluginsLock);