summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2012-12-05 11:36:25 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-05 17:29:46 +0100
commitfd4106e2d110a361208a6289cee18c5847377cb1 (patch)
tree8ec5d37b9982e38cb3b3d97ac9395fb33bf9e743 /src/plugins/platforms/cocoa
parentfd1f65a9b84d597078482cd420771620c406f8da (diff)
Cocoa: fix unresponsive dialogs causes application to hang
The reason for this bug seems to be related to how we wait for more events in the event dispatcher. We use the nextEventMatchingMask function, which already in Qt4 showed to have problems when telling it to not dequeue the event. The solution back then was to tell it to dequeue the event, and instead repost in front again. Why this was changed in Qt5 is uncertain (other than it being tempting) but moving the same code back in will solve the bug. Note that this bug might also stem from the fact that the run loop sources we add in the event dispatcher fires before the application is really ready to show modal dialogs. E.g refusing to execute a modal dialog before NSAppDelegate applicationWillFinishLaunching is called will also fix the problem. But this code change is to big atm, and can easily introduce other unforeseen regressions. Task-number: QTBUG-28283 Change-Id: I07cd109568c2b9c782cf5120a9eb2ac71128cada Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 7aa365df67..80c9e227d2 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -510,14 +510,16 @@ static bool IsMouseOrKeyEvent( NSEvent* event )
static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRunLoopMode)
{
- // If no event exist in the cocoa event que, wait
- // (and free up cpu time) until at least one event occur.
- // This implementation is a bit on the edge, but seems to
- // work fine:
- [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantFuture]
- inMode:runLoopMode
- dequeue:NO];
+ // If no event exist in the cocoa event que, wait (and free up cpu time) until
+ // at least one event occur. Setting 'dequeuing' to 'no' in the following call
+ // causes it to hang under certain circumstances (QTBUG-28283), so we tell it
+ // to dequeue instead, just to repost the event again:
+ NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantFuture]
+ inMode:runLoopMode
+ dequeue:YES];
+ if (event)
+ [NSApp postEvent:event atStart:YES];
}
bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)