summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-09-26 17:39:32 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-09-27 15:53:04 +0000
commit1402f5d16e792c37a81af45fa3cd662e2da21910 (patch)
tree5aff865edc80afcce98c18d00eaef8ce76e8b046 /src/testlib
parent9fcbef15f662cffb134925dc449ae8586cad44e4 (diff)
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>
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestsystem.h19
1 files changed, 16 insertions, 3 deletions
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