Stabilize auto test

Don't just wait for 300ms for the thread to finish, this can
lead to faling tests esp. on slow hardware.

Also fix a mem leak.

Change-Id: Ifa90da5507fc6d65ef77e368d7c238271623ff53
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
This commit is contained in:
Lars Knoll 2019-03-25 12:18:30 +01:00 committed by Jędrzej Nowacki
parent a868412a78
commit 4a470101e4

View File

@ -378,6 +378,10 @@ public:
connect(timer, &QTimer::timeout, this, &DeleteReceiverRaceReceiver::onTimeout);
timer->start(1);
}
~DeleteReceiverRaceReceiver()
{
delete receiver;
}
void onTimeout()
{
@ -428,12 +432,12 @@ void tst_QObjectRace::disconnectRace()
for (int i = 0; i < ThreadCount; ++i) {
threads[i]->requestInterruption();
QVERIFY(threads[i]->wait(300));
QVERIFY(threads[i]->wait());
delete threads[i];
}
senderThread->quit();
QVERIFY(senderThread->wait(300));
QVERIFY(senderThread->wait());
}
QCOMPARE(countedStructObjectsCount.load(), 0u);
@ -453,11 +457,11 @@ void tst_QObjectRace::disconnectRace()
QTest::qWait(TimeLimit);
senderThread->requestInterruption();
QVERIFY(senderThread->wait(300));
QVERIFY(senderThread->wait());
for (int i = 0; i < ThreadCount; ++i) {
threads[i]->quit();
QVERIFY(threads[i]->wait(300));
QVERIFY(threads[i]->wait());
delete threads[i];
}
}