Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.9.4
-
None
Description
I have 3D application on Windows. I start an asynchronous computation on another thread and in the main thread I'm waiting for the result with a loop like this:
while(!task.IsFinished())
{
QCoreApplication::processEvents(QEventLoop::AllEvents, 10);
}
This way, I'm expecting to check the condition roughly every 10ms.
However, if I have continuously repaint events arriving in the event queue (if the user rotate the 3D scene), then processEvents() doesn't return as expected after 10ms (more or less) but only when the user stop rotating the 3D scene (i.e. when there's no more repaint event).
I have debugged what's happening in the Qt sources, it leads me to the file QEventDispatcher_win.cpp:
bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) { [...] while(!d->interrupt) { bool haveMessage; [...] haveMessage = PeekMessage(&msg, 0, 0, 0, PM_REMOVE); [...] if(haveMessage) { [...] } else { // nothing todo so break break; } } [...] }
I have simplified the body of the function:
- first of all, this function doesn't take the maxTime. so it cannot break when the elapsed time exceed the maxTime.
- when looking at the while(!d->interrupt) loop, the only way to get out this loop is that haveMessage == false, which means PeekMessage() returns no message so that the message queue must be empty.
I may be wrong, but the maxTime parameter should be propagated down to the QEventDispatcher implementations.