diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-04-19 15:22:35 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-04-19 15:23:32 (GMT) |
commit | dfa8d13a20548c31b56678df517ae38e85fe1384 (patch) | |
tree | f402a4273958b7d388971653a3261cececa3d733 | |
parent | 1f0104850aafcb0e2d6af3fcd4d61ae7073c6e3d (diff) | |
download | Qt-dfa8d13a20548c31b56678df517ae38e85fe1384.zip Qt-dfa8d13a20548c31b56678df517ae38e85fe1384.tar.gz Qt-dfa8d13a20548c31b56678df517ae38e85fe1384.tar.bz2 |
Don't deadlock tst_QThread::exit() and tst_QThread::quit()
Make sure to lock the mutex before starting the threads... otherwise we
run the risk of losing the wakeup between start() and the lock being
acquired.
Reviewed-by: TrustMe
-rw-r--r-- | tests/auto/qthread/tst_qthread.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp index 9a4397e..7a5b053 100644 --- a/tests/auto/qthread/tst_qthread.cpp +++ b/tests/auto/qthread/tst_qthread.cpp @@ -442,9 +442,9 @@ void tst_QThread::exit() thread2.object = 0; thread2.code = 53; thread2.result = 0; + QMutexLocker locker2(&thread2.mutex); thread2.start(); thread2.exit(thread2.code); - QMutexLocker locker2(&thread2.mutex); thread2.cond.wait(locker2.mutex()); QVERIFY(thread2.wait(five_minutes)); QCOMPARE(thread2.result, thread2.code); @@ -514,9 +514,9 @@ void tst_QThread::quit() Quit_Thread thread2; thread2.object = 0; thread2.result = -1; + QMutexLocker locker2(&thread2.mutex); thread2.start(); thread2.quit(); - QMutexLocker locker2(&thread2.mutex); thread2.cond.wait(locker2.mutex()); QVERIFY(thread2.wait(five_minutes)); QCOMPARE(thread2.result, 0); |