processEvents(WaitForMoreEvents) should return after delivering events
authorBradley T. Hughes <bradley.hughes@nokia.com>
Mon, 23 Jan 2012 07:59:27 +0000 (08:59 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 3 Feb 2012 00:40:24 +0000 (01:40 +0100)
commitb7ca6a81dbf6a2b96c8f04b856372050618e60c0
tree58ae6adda02901ef8d035fc96734044a1f64fbcd
parentda5d9e664f27abe41748f4360624c235c20e8c15
processEvents(WaitForMoreEvents) should return after delivering events

The Cocoa event dispatcher sends timer, socket, and posted events
correctly, but they are not NSEvents, and as such, they do not cause
[NSApp nextEventMatchingMask] to return. When calling processEvents()
with WaitForMoreEvents, but the EventLoopExec flag isn't set, we want to
interrupt the WaitForMoreEvents.

As a result, We should not call wakeUp() at the top of processEvents(),
otherwise we end up shortcutting other event sources. We also do not
need to call QCoreApplication::sendPostedEvents() directly either in
processEvents(), it's the postedEventsSource job to do that.

The interruptLater mechanism is always run when calling processEvents()
directly (not via exec()), which causes problems when testing
processEvents(). Don't use interruptLater unless the modal sessions
change (which is indicated by the cached session pointer being reset
to zero).

Change-Id: Iec2b49a4f306b2702c979522f12a28d0b5fbd0b4
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm