summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-05-01 10:00:08 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-05-05 23:21:52 -0700
commit1373a20f9998d66e8a928628f568b54e8ac8d1ed (patch)
tree6b064ec7844b6d9204d49c5e9b80c7708851ed30 /src
parent25e13c9079fbc441ecf37c8a601dd88cdebd0b49 (diff)
QTestEventLoop: don't stop the test fails outside the main thread
This amends commit 115f828ae406d2805869fccda9269209af646a84 "QTestEventLoop: stop when the test fails" from Qt 6.3 to not attempt to stop the QTestEventLoop instance if the failure happened outside the main thread. This is to prevent the QTEL from being created outside the main thread and thus cause warnings about QObject in addition to and logged before the real test failure. [ChangeLog][QtTest][QTestEventLoop] The QTestEventLoop no longer attempts to exit its event loop if the failure was detected outside the main thread. QWARN : tst_QMutex::tryLock_non_recursive() QObject: Cannot create children for a parent that is in a different thread. (Parent is QCoreApplication(0x7fffffffe710), parent's thread is QThread(0x802e29000), current thread is QThread(0x7fffffffd5a8) FAIL! : tst_QMutex::tryLock_non_recursive() 'timer.elapsed() >= waitTime - systemTimersResolution' returned FALSE. () Change-Id: Ieab617d69f3b4b54ab30fffd175b139322a1f02c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtestresult.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index e3545802cb..d5f43ee8e0 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -534,7 +534,8 @@ bool QTestResult::compare(bool success, const char *failureMsg,
void QTestResult::addFailure(const char *message, const char *file, int line)
{
clearExpectFail();
- QTestEventLoop::instance().exitLoop();
+ if (qApp && QThread::currentThread() == qApp->thread())
+ QTestEventLoop::instance().exitLoop();
if (QTest::blacklistCurrentTest)
QTestLog::addBFail(message, file, line);