summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-24 11:01:17 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-24 09:09:03 +0000
commit5fd3539cfd944bb8f7cd2d7ec828dd963aa6505d (patch)
tree89ac57b3f645beaa0eac1a11ba88348f02527f8a /src/testlib/qtestcase.cpp
parent71203b1f0ec2da27d4cc03a82162eb7f643cc525 (diff)
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>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 41e0b70d21..6799ae1087 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -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)