tst_qthread: Don't use QVERIFY in multiple threads in threadIdReuse()
Testlib is not thread safe. Store the status into variable and check it in the main thread instead. Pick-to: 6.2 Change-Id: I840c8a3dceb1115a1b81ffeaa0fab96f9d2f1ff0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
44a7412795
commit
e0b87edd73
@ -1660,14 +1660,17 @@ void tst_QThread::threadIdReuse()
|
|||||||
QThread::msleep(1);
|
QThread::msleep(1);
|
||||||
|
|
||||||
Qt::HANDLE threadId2;
|
Qt::HANDLE threadId2;
|
||||||
auto waitForThread1 = [&thread1, &threadId2]() -> void {
|
bool waitOk = false;
|
||||||
|
|
||||||
|
auto waitForThread1 = [&thread1, &threadId2, &waitOk]() -> void {
|
||||||
threadId2 = QThread::currentThreadId();
|
threadId2 = QThread::currentThreadId();
|
||||||
QVERIFY(thread1->wait());
|
waitOk = thread1->wait();
|
||||||
};
|
};
|
||||||
|
|
||||||
QScopedPointer<QThread> thread2(QThread::create(waitForThread1));
|
QScopedPointer<QThread> thread2(QThread::create(waitForThread1));
|
||||||
thread2->start();
|
thread2->start();
|
||||||
QVERIFY(thread2->wait());
|
QVERIFY(thread2->wait());
|
||||||
|
QVERIFY(waitOk);
|
||||||
|
|
||||||
if (threadId1 == threadId2) {
|
if (threadId1 == threadId2) {
|
||||||
qDebug("Thread ID reused at iteration %d", i);
|
qDebug("Thread ID reused at iteration %d", i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user