aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-29 12:51:23 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-30 09:08:59 +0000
commit52e782bdc56fb3a62b045f2d1ca71f38bc7ef796 (patch)
tree28d9af308072c1dbedb39b9e333024ad43d3e6be
parent38b14d6646957b2ac4f1d0248a4d0390adb270ab (diff)
Make sure QQmlDebugServer does not deadlock in blocking mode
Previously, the server could wake the helloCondition before the main thread was waiting on it. This would lead to the main thread then waiting forever once it hit the wait() statement. Change-Id: I694d65f72cf6be6e4c5a0c65ea4aea8a5878bf5b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/qml/debugger/qqmldebugserver.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp
index 4d5e3f5605..4974bce8d8 100644
--- a/src/qml/debugger/qqmldebugserver.cpp
+++ b/src/qml/debugger/qqmldebugserver.cpp
@@ -222,7 +222,6 @@ struct StartTcpServerAction {
if (!d->init(QLatin1String("qmldbg_tcp"), block))
return false;
d->m_thread->setPortRange(portFrom, portTo == -1 ? portFrom : portTo, block, hostAddress);
- d->m_thread->start();
return true;
}
};
@@ -239,7 +238,6 @@ struct ConnectToLocalAction {
if (!d->init(QLatin1String("qmldbg_local"), block))
return false;
d->m_thread->setFileName(fileName, block);
- d->m_thread->start();
return true;
}
};
@@ -372,7 +370,12 @@ void QQmlDebugServerThread::run()
}
}
- server->m_connection = connection;
+ {
+ QMutexLocker connectionLocker(&server->m_helloMutex);
+ server->m_connection = connection;
+ server->m_helloCondition.wakeAll();
+ }
+
if (m_block)
connection->waitForConnection();
} else {
@@ -790,13 +793,11 @@ bool QQmlDebugServerImpl::enable(Action action)
return false;
if (!action(this))
return false;
- while (!m_connection) {
- if (!m_thread)
- return false;
- }
QMutexLocker locker(&m_helloMutex);
+ m_thread->start();
+ m_helloCondition.wait(&m_helloMutex); // wait for connection
if (m_blockingMode && !m_gotHello)
- m_helloCondition.wait(&m_helloMutex);
+ m_helloCondition.wait(&m_helloMutex); // wait for hello
return true;
#else
Q_UNUSED(action);