From ada4b4aaa5ccb9a41a42eb2b4f8f0e7625e8ef9c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 27 Oct 2015 12:23:42 +0100 Subject: Attach all signal spies before setting the watcher's future. Attaching spies afterwards was provoking a warning during tests: QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race Change-Id: I6ee8c3613cecebd1c69b0337139d8a19a33f4a11 Reviewed-by: Marc Mutz --- .../thread/qfuturewatcher/tst_qfuturewatcher.cpp | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'tests/auto/corelib/thread/qfuturewatcher') diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index 5ec32b1d02..f64d92dcdb 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -313,10 +313,16 @@ void tst_QFutureWatcher::futureSignals() // (QSignalSpy does not trigger it.) connect(&f, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); a.reportStarted(); - f.setFuture(a.future()); QSignalSpy progressSpy(&f, &QFutureWatcher::progressValueChanged); + QSignalSpy finishedSpy(&f, &QFutureWatcher::finished); + QSignalSpy resultReadySpy(&f, &QFutureWatcher::resultReadyAt); + QVERIFY(progressSpy.isValid()); + QVERIFY(finishedSpy.isValid()); + QVERIFY(resultReadySpy.isValid()); + f.setFuture(a.future()); + const int progress = 1; a.setProgressValue(progress); QTest::qWait(10); @@ -324,12 +330,6 @@ void tst_QFutureWatcher::futureSignals() QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0); QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1); - QSignalSpy finishedSpy(&f, &QFutureWatcher::finished); - QSignalSpy resultReadySpy(&f, &QFutureWatcher::resultReadyAt); - - QVERIFY(finishedSpy.isValid()); - QVERIFY(resultReadySpy.isValid()); - const int result = 10; a.reportResult(&result); QTest::qWait(10); @@ -427,16 +427,15 @@ void tst_QFutureWatcher::disconnectRunningFuture() QFuture f = a.future(); QFutureWatcher *watcher = new QFutureWatcher(); - watcher->setFuture(f); - - SignalSlotObject object; - connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy finishedSpy(watcher, &QFutureWatcher::finished); QSignalSpy resultReadySpy(watcher, &QFutureWatcher::resultReadyAt); QVERIFY(finishedSpy.isValid()); QVERIFY(resultReadySpy.isValid()); + watcher->setFuture(f); + + SignalSlotObject object; + connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); const int result = 10; a.reportResult(&result); -- cgit v1.2.3