diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-09-03 11:18:09 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-09-06 00:17:14 +0200 |
commit | a0e0b51001edfc1c7aea113c472ce995efa833fd (patch) | |
tree | 9a7f2b424806338301c0c262b5d268b94ec1ef61 /src/corelib/kernel/qtestsupport_core.cpp | |
parent | 75d1d2a91376c3338510cf1e5fa10feaf8df5785 (diff) |
Inline QTest::qSleep()
Simply use QThread::msleep() to implement it.
Change-Id: I37c255fc70951715edc489d9f67669b01af380b1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel/qtestsupport_core.cpp')
-rw-r--r-- | src/corelib/kernel/qtestsupport_core.cpp | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/corelib/kernel/qtestsupport_core.cpp b/src/corelib/kernel/qtestsupport_core.cpp index 928c8021bc..e6e3dfbd69 100644 --- a/src/corelib/kernel/qtestsupport_core.cpp +++ b/src/corelib/kernel/qtestsupport_core.cpp @@ -45,18 +45,6 @@ QT_BEGIN_NAMESPACE -Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) -{ - Q_ASSERT(ms > 0); - -#if defined(Q_OS_WIN) - Sleep(uint(ms)); -#else - struct timespec ts = { time_t(ms / 1000), (ms % 1000) * 1000 * 1000 }; - nanosleep(&ts, nullptr); -#endif -} - /*! \fn template <typename Functor> bool QTest::qWaitFor(Functor predicate, int timeout) Waits for \a timeout milliseconds or until the \a predicate returns true. @@ -88,25 +76,5 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms) \sa QTest::qSleep(), QSignalSpy::wait() */ -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; - QTestPrivate::qSleep(qMin(10, remaining)); - remaining = timer.remainingTime(); - } while (remaining > 0); -} QT_END_NAMESPACE |