From faa6113c41b81368c5bbc2a764c2ae9bbc42e415 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 3 Nov 2011 11:10:44 +0100 Subject: [PATCH] Fix unstable test due to a race in QThread QThread::finished() is emitted before setting the thread's state to finished and !running, which means it's possible to receive the finished() signal and act on it while QThread::isRunning() still returns true. This test randomly fails due to this race. Fix it by using checking the return value of QThread::wait() instead. Change-Id: Ibf347fc9a2e8d32b328227ee6978e1129dd781f4 Reviewed-by: Thiago Macieira --- tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp index ce879273eb..face4742b1 100644 --- a/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp +++ b/tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp @@ -392,7 +392,7 @@ void tst_QDBusPendingCall::watcher_waitForFinished_threaded() QTestEventLoop::instance().connect(&thread, SIGNAL(finished()), SLOT(exitLoop())); thread.start(); QTestEventLoop::instance().enterLoop(10); - QVERIFY(!thread.isRunning()); + QVERIFY(thread.wait(3000)); QVERIFY(!QTestEventLoop::instance().timeout()); }