QTest::qWaitFor: scope std::chrono using directive tighter
... moving it away from between a comment and the C++ code the comment pertains to. Change-Id: I56b3ded01d1800bae19121e4b9340d0c43f1da85 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit c1d1437b4a8609f4b6e7eb5f39352d4951b4f507)
This commit is contained in:
parent
449551eea1
commit
bf7eff0188
@ -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
|
// qWait() is expected to spin the event loop at least once, even when
|
||||||
// called with a small timeout like 1ns.
|
// called with a small timeout like 1ns.
|
||||||
|
|
||||||
using namespace std::chrono;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// We explicitly do not pass the remaining time to processEvents, as
|
// We explicitly do not pass the remaining time to processEvents, as
|
||||||
// that would keep spinning processEvents for the whole duration if
|
// that would keep spinning processEvents for the whole duration if
|
||||||
@ -43,6 +41,8 @@ qWaitFor(Functor predicate, QDeadlineTimer deadline = QDeadlineTimer(std::chrono
|
|||||||
if (predicate())
|
if (predicate())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
if (const auto remaining = deadline.remainingTimeAsDuration(); remaining > 0ns)
|
if (const auto remaining = deadline.remainingTimeAsDuration(); remaining > 0ns)
|
||||||
qSleep((std::min)(10ms, ceil<milliseconds>(remaining)));
|
qSleep((std::min)(10ms, ceil<milliseconds>(remaining)));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user