Workaround GCC 6 parsing error ("used but never defined")

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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
Thiago Macieira 2017-09-26 17:39:32 -07:00
parent 9fcbef15f6
commit 1402f5d16e

View File

@ -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