diff options
author | Kai Koehne <kai.koehne@digia.com> | 2013-04-23 11:49:36 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-23 15:40:31 +0200 |
commit | a028d463508ed0612f7fd1d2b1365c5c091dc1b4 (patch) | |
tree | 9ac4a2f48d765ff2d022acf6797c99764efe627f /src/qml/debugger/qqmldebugserver.cpp | |
parent | 33e0dd64f9cb4e517d1fc126e645b341803fb481 (diff) |
Debugger: fix race condition in block mode
Make sure that the GUI thread & debugger thread actually sync on startup. So far
the GUI thread would block forever in waitCondition.wait() if the debugger thread
spawns & receives the HELLO before.
Also remove unused code and rename variables to make their use more obvious.
Change-Id: I8285e8860667496d491807e696535353d9f14dea
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
Diffstat (limited to 'src/qml/debugger/qqmldebugserver.cpp')
-rw-r--r-- | src/qml/debugger/qqmldebugserver.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp index e263343b0d..dcb553912d 100644 --- a/src/qml/debugger/qqmldebugserver.cpp +++ b/src/qml/debugger/qqmldebugserver.cpp @@ -102,9 +102,8 @@ public: bool gotHello; bool blockingMode; - QMutex messageArrivedMutex; - QWaitCondition messageArrivedCondition; - QStringList waitingForMessageNames; + QMutex helloMutex; + QWaitCondition helloCondition; QQmlDebugServerThread *thread; QPluginLoader loader; QAtomicInt changeServiceStateCalls; @@ -331,11 +330,11 @@ QQmlDebugServer *QQmlDebugServer::instance() QQmlDebugServerPrivate *d = qQmlDebugServer->d_func(); d->blockingMode = block; - QMutexLocker locker(&d->messageArrivedMutex); + QMutexLocker locker(&d->helloMutex); thread->start(); if (d->blockingMode) - d->messageArrivedCondition.wait(&d->messageArrivedMutex); + d->helloCondition.wait(&d->helloMutex); } else { qWarning() << QString(QLatin1String( @@ -447,7 +446,8 @@ void QQmlDebugServer::receiveMessage(const QByteArray &message) d->_q_changeServiceState(iter.value()->name(), newState); } - d->messageArrivedCondition.wakeAll(); + QMutexLocker helloLock(&d->helloMutex); + d->helloCondition.wakeAll(); } else if (op == 1) { @@ -487,9 +487,6 @@ void QQmlDebugServer::receiveMessage(const QByteArray &message) qWarning() << "QML Debugger: Message received for missing plugin" << name << '.'; } else { (*iter)->messageReceived(message); - - if (d->waitingForMessageNames.removeOne(name)) - d->messageArrivedCondition.wakeAll(); } } else { qWarning("QML Debugger: Invalid hello message."); |