From dfa8d13a20548c31b56678df517ae38e85fe1384 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 19 Apr 2010 17:22:35 +0200 Subject: 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 --- tests/auto/qthread/tst_qthread.cpp | 4 ++-- 1 file 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); -- cgit v0.12