diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-11-26 14:11:16 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-12-09 20:54:25 +0100 |
commit | 5c908c826313143a65ef7e95e5af6625fe1ba813 (patch) | |
tree | 01efec7a6fe7fe79a510ebbf1c9208bc8d615136 /src | |
parent | d41d3274d430922883afd714d87d81cf0e62d5d9 (diff) |
Implement QTest::qWait() in terms of QTest::qWaitFor()
A comment in the existing implementation encouraged doing so, but for
a bug in GCC 6. We no longer care.
Change-Id: Ia8cb2bc5e184510e3d756e8bbfe6bc0e852e6830
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qtestsupport_core.cpp | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index f5b6ed18cd..01ff571379 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -107,23 +107,7 @@ Q_CORE_EXPORT void QTest::qSleep(int ms) */ Q_CORE_EXPORT void QTest::qWait(int ms) { - // Ideally this method would be implemented in terms of qWaitFor, with - // a predicate that always returns false, but due to a compiler bug in - // GCC 6 we can't do that. - - Q_ASSERT(QCoreApplication::instance()); - - QDeadlineTimer timer(ms, Qt::PreciseTimer); - int remaining = ms; - do { - QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); - remaining = timer.remainingTime(); - if (remaining <= 0) - break; - QTest::qSleep(qMin(10, remaining)); - remaining = timer.remainingTime(); - } while (remaining > 0); + (void)qWaitFor([]() { return false; }, ms); } QT_END_NAMESPACE |