From 1402f5d16e792c37a81af45fa3cd662e2da21910 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Sep 2017 17:39:32 -0700 Subject: Workaround GCC 6 parsing error ("used but never defined") MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 7 and other compilers compile this code just fine. GCC 6 fails, so this is clearly a compiler bug. So revert the implementation of the qWait() function back to the original, to make the problem disappear. qtestsystem.h:58:42: error: ‘bool QTest::qWaitFor(Functor, int) [with Functor = bool (*)()]’ used but never defined [-Werror] Change-Id: I0b48fc8e90304e0dacc3fffd14e8110138cc9f45 Reviewed-by: Tor Arne Vestbø --- src/testlib/qtestsystem.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index f22a16decb..687219c521 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -90,10 +90,23 @@ namespace QTest Q_DECL_UNUSED inline static void 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()); - auto unconditionalWait = []() { return false; }; - bool timedOut = !qWaitFor(unconditionalWait, ms); - Q_UNUSED(timedOut); + + QDeadlineTimer timer(ms, Qt::PreciseTimer); + int remaining = ms; + do { + QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); + QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); + remaining = timer.remainingTime(); + if (remaining <= 0) + break; + QTest::qSleep(qMin(10, remaining)); + remaining = timer.remainingTime(); + } while (remaining > 0); } #ifdef QT_GUI_LIB -- cgit v1.2.3