From bbc8536f6e1fb31d1b4f652750f76b4a26e1d54a Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 24 Aug 2010 09:45:56 +0200 Subject: Stabilize tst_QFutureWatcher::warnRace --- tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp index 8b52761..183f62c 100644 --- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp @@ -47,6 +47,7 @@ #include #include #include +#include "../../shared/util.h" #ifndef QT_NO_CONCURRENT_TEST #include @@ -891,6 +892,13 @@ class DummyObject : public QObject { Q_OBJECT public slots: void dummySlot() {} +public: + static void function(QWaitCondition *cond) + { + QMutex m; + QMutexLocker lock(&m); + cond->wait(&m); + } }; void tst_QFutureWatcher::warnRace() @@ -900,14 +908,16 @@ void tst_QFutureWatcher::warnRace() #endif QFutureWatcher watcher; DummyObject object; + QWaitCondition cond; - QFuture future = QtConcurrent::run(sleeper); + QFuture future = QtConcurrent::run(DummyObject::function, &cond); watcher.setFuture(future); + QTRY_VERIFY(future.isStarted()); connect(&watcher, SIGNAL(finished()), &object, SLOT(dummySlot())); + cond.wakeAll(); future.waitForFinished(); } - #include "tst_qfuturewatcher.moc" #else -- cgit v0.12