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 <thiago.macieira@intel.com>
This commit is contained in:
parent
ec5e59b73c
commit
faa6113c41
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user