From e0b87edd73c4ade9f35985313b19d8f2f1f9ca78 Mon Sep 17 00:00:00 2001 From: Ievgenii Meshcheriakov Date: Thu, 30 Sep 2021 16:10:02 +0200 Subject: [PATCH] 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 Reviewed-by: Thiago Macieira --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 704eb14e142..a396ebffc2b 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -1660,14 +1660,17 @@ void tst_QThread::threadIdReuse() QThread::msleep(1); Qt::HANDLE threadId2; - auto waitForThread1 = [&thread1, &threadId2]() -> void { + bool waitOk = false; + + auto waitForThread1 = [&thread1, &threadId2, &waitOk]() -> void { threadId2 = QThread::currentThreadId(); - QVERIFY(thread1->wait()); + waitOk = thread1->wait(); }; QScopedPointer thread2(QThread::create(waitForThread1)); thread2->start(); QVERIFY(thread2->wait()); + QVERIFY(waitOk); if (threadId1 == threadId2) { qDebug("Thread ID reused at iteration %d", i);