From 530607d8ba0dac8d91d20ec0e62d3129cb21e225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 15 May 2014 13:29:25 +0200 Subject: Cocoa: Fix modal session cleanup. Call [NSApp endModalSession] at the correct time. Calling cleanupModalSessions() from processPostedEvents() resulted in endModalSession being called from within [NSApp runModalSession] - ending and cleaning up the the modal session while Cocoa is still using it. Move the cleanupModalSessions() call to to after runModalSession returns. Task-number: QTBUG-37699 Change-Id: I5868def36f6869667b0bbe33733286e3e49488eb Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 96a8fa1ad4..9aaf08adcf 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -415,6 +415,11 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) // 'session' as well. As a result, we need to restart all internal sessions: d->temporarilyStopAllModalSessions(); } + + // Clean up the modal session list, call endModalSession. + if (d->cleanupModalSessionsNeeded) + d->cleanupModalSessions(); + } else { d->nsAppRunCalledByQt = true; QBoolBlocker execGuard(d->currentExecIsNSAppRun, true); @@ -441,6 +446,11 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) // 'session' as well. As a result, we need to restart all internal sessions: d->temporarilyStopAllModalSessions(); } + + // Clean up the modal session list, call endModalSession. + if (d->cleanupModalSessionsNeeded) + d->cleanupModalSessions(); + retVal = true; } else do { // Dispatch all non-user events (but que non-user events up for later). In @@ -860,9 +870,6 @@ void QCocoaEventDispatcherPrivate::processPostedEvents() return; } - if (cleanupModalSessionsNeeded) - cleanupModalSessions(); - if (interrupt) { if (currentExecIsNSAppRun) { // The event dispatcher has been interrupted. But since -- cgit v1.2.3