From a373648fa876a9684394aa9b7ecafd51e53f4742 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 26 Aug 2010 11:10:02 +0200 Subject: Cocoa: Demo browser can get stuck after closing modal dialog This turns out to be a glitch in the event dispatcher for Qt/Cocoa. The problem is that you can, in some really slim cases it must be, end up calling processEvents with the exec flag set, while the current modal dialog has been told to leave modal. In that case, we recurse into a new event dispatching loop for a session that is about to die. And that causes problems when the session actually dies. This patch makes sure that you cannon start spinning a session that is about to die, by setting the sessionCache to zero. Task-number: QTBUG-13164 Reviewed-by: Tor Arne --- src/gui/kernel/qeventdispatcher_mac.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 89f01d8..515c6d3 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -830,6 +830,7 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession() [window setLevel:levelBeforeEnterModal]; } currentModalSessionCached = info.session; + cleanupModalSessionsNeeded = false; } return currentModalSessionCached; } @@ -881,6 +882,10 @@ void QEventDispatcherMacPrivate::cleanupModalSessions() for (int i=stackSize-1; i>=0; --i) { QCocoaModalSessionInfo &info = cocoaModalSessionStack[i]; if (info.widget) { + // This session has a widget, and is therefore not marked + // as stopped. So just make it current. There might still be other + // stopped sessions on the stack, but those will be stopped on + // a later "cleanup" call. currentModalSessionCached = info.session; break; } @@ -926,6 +931,7 @@ void QEventDispatcherMacPrivate::endModalSession(QWidget *widget) if (i == stackSize-1) { // The top sessions ended. Interrupt the event dispatcher // to start spinning the correct session immidiatly: + currentModalSessionCached = 0; cleanupModalSessionsNeeded = true; QEventDispatcherMac::instance()->interrupt(); } -- cgit v0.12