diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-24 15:40:55 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-08-24 15:42:46 (GMT) |
commit | 5988bb71724bf28811b8a7324aea91e3ca75492f (patch) | |
tree | 7d67604e3a6fd56d0a40efea6acfb04c5328af4e | |
parent | 3ba16e3923003a7919eb157ae3375792b714484e (diff) | |
download | Qt-5988bb71724bf28811b8a7324aea91e3ca75492f.zip Qt-5988bb71724bf28811b8a7324aea91e3ca75492f.tar.gz Qt-5988bb71724bf28811b8a7324aea91e3ca75492f.tar.bz2 |
Stabilize tst_QFutureWatcher::warnRace (second attempt)
-rw-r--r-- | tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp | 13 |
1 files 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<void> watcher; DummyObject object; - QWaitCondition cond; + QMutex mutex; + mutex.lock(); - QFuture<void> future = QtConcurrent::run(DummyObject::function, &cond); + QFuture<void> 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(); } |