Improve safety of QTestLib watchdog

Reduce the side-effects of QThread start-up happening concurrently while test
functions begin to execute by terminating the WatchDog constructor only when
the thread itself is up and running.

Change-Id: I21ee44206d789a7ecb5a220ee4729572548c0277
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Simon Hausmann 2015-04-24 11:01:17 +02:00
parent 71203b1f0e
commit 5fd3539cfd

View File

@ -2046,8 +2046,10 @@ class WatchDog : public QThread
public:
WatchDog()
{
QMutexLocker locker(&mutex);
timeout.store(-1);
start();
waitCondition.wait(&mutex);
}
~WatchDog() {
{
@ -2072,6 +2074,7 @@ public:
void run() {
QMutexLocker locker(&mutex);
waitCondition.wakeAll();
while (1) {
int t = timeout.load();
if (!t)