QTest::qWaitFor: scope std::chrono using directive tighter

... moving it away from between a comment and the C++ code the comment
pertains to.

Pick-to: 6.7
Change-Id: I56b3ded01d1800bae19121e4b9340d0c43f1da85
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
bb10
Marc Mutz 2024-03-11 12:55:36 +01:00
parent 59549657a3
commit c1d1437b4a
1 changed files with 2 additions and 2 deletions

View File

@ -28,8 +28,6 @@ qWaitFor(Functor predicate, QDeadlineTimer deadline = QDeadlineTimer(std::chrono
// qWait() is expected to spin the event loop at least once, even when
// called with a small timeout like 1ns.
using namespace std::chrono;
do {
// We explicitly do not pass the remaining time to processEvents, as
// that would keep spinning processEvents for the whole duration if
@ -43,6 +41,8 @@ qWaitFor(Functor predicate, QDeadlineTimer deadline = QDeadlineTimer(std::chrono
if (predicate())
return true;
using namespace std::chrono;
if (const auto remaining = deadline.remainingTimeAsDuration(); remaining > 0ns)
qSleep((std::min)(10ms, ceil<milliseconds>(remaining)));