diff --git a/src/testlib/qtesteventloop.h b/src/testlib/qtesteventloop.h index d576de4267..10bb4f3f96 100644 --- a/src/testlib/qtesteventloop.h +++ b/src/testlib/qtesteventloop.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtTest module of the Qt Toolkit. @@ -41,6 +41,7 @@ #define QTESTEVENTLOOP_H #include +#include #include #include @@ -93,11 +94,12 @@ private: inline void QTestEventLoop::enterLoopMSecs(int ms) { Q_ASSERT(!loop); - - QEventLoop l; - _timeout = false; + if (QTest::currentTestFailed()) + return; + + QEventLoop l; timerId = startTimer(ms); loop = &l; diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index 7498b92024..581e8bc33b 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -464,6 +465,7 @@ bool QTestResult::compare(bool success, const char *failureMsg, void QTestResult::addFailure(const char *message, const char *file, int line) { clearExpectFail(); + QTestEventLoop::instance().exitLoop(); if (QTest::blacklistCurrentTest) QTestLog::addBFail(message, file, line);