Ensure that posted events are sent by Q*Application::processEvents()

Commit b7ca6a81db removed a call to
sendPostedEvents() that deemed unnecessary. Unfortunately, it is
necessary, as shown by the
tst_QScriptEngine::processEventsWhileRunning() test in the QtScript
module. Re-add the call, but only when not waiting for more events.

Change-Id: I648d66dd3ba484ad9e9a93fc03a9792cca5035c6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
This commit is contained in:
Bradley T. Hughes 2012-02-06 16:13:45 +01:00 committed by Qt by Nokia
parent 36f5cc848d
commit 3722bc5d3c

View File

@ -569,6 +569,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
} }
retVal = true; retVal = true;
} else { } else {
int lastSerialCopy = d->lastSerial;
bool hadModalSession = d->currentModalSessionCached != 0; bool hadModalSession = d->currentModalSessionCached != 0;
// We cannot block the thread (and run in a tight loop). // We cannot block the thread (and run in a tight loop).
// Instead we will process all current pending events and return. // Instead we will process all current pending events and return.
@ -631,6 +632,14 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
} }
} while (!d->interrupt && event != nil); } while (!d->interrupt && event != nil);
if ((flags & QEventLoop::WaitForMoreEvents) == 0) {
// when called "manually", always send posted events
d->processPostedEvents();
}
// be sure to return true if the posted event source fired
retVal = retVal || lastSerialCopy != d->lastSerial;
// Since the window that holds modality might have changed while processing // Since the window that holds modality might have changed while processing
// events, we we need to interrupt when we return back the previous process // events, we we need to interrupt when we return back the previous process
// event recursion to ensure that we spin the correct modal session. // event recursion to ensure that we spin the correct modal session.