From 5988bb71724bf28811b8a7324aea91e3ca75492f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 24 Aug 2010 17:40:55 +0200 Subject: Stabilize tst_QFutureWatcher::warnRace (second attempt) --- tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp index 183f62c..c980d80 100644 --- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp @@ -893,11 +893,9 @@ class DummyObject : public QObject { public slots: void dummySlot() {} public: - static void function(QWaitCondition *cond) + static void function(QMutex *m) { - QMutex m; - QMutexLocker lock(&m); - cond->wait(&m); + QMutexLocker lock(m); } }; @@ -908,13 +906,14 @@ void tst_QFutureWatcher::warnRace() #endif QFutureWatcher watcher; DummyObject object; - QWaitCondition cond; + QMutex mutex; + mutex.lock(); - QFuture future = QtConcurrent::run(DummyObject::function, &cond); + QFuture future = QtConcurrent::run(DummyObject::function, &mutex); watcher.setFuture(future); QTRY_VERIFY(future.isStarted()); connect(&watcher, SIGNAL(finished()), &object, SLOT(dummySlot())); - cond.wakeAll(); + mutex.unlock(); future.waitForFinished(); } -- cgit v0.12