--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm 2016-03-16 11:21:51.000000000 0100 +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm 2016-03-16 11:21:51.000000000 0100 @@ -396,9 +396,19 @@ // [NSApp run], which is the normal code path for cocoa applications. if (NSModalSession session = d->currentModalSession()) { QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); - while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) + while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) { qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode); - + // Clean up the modal session list + if (d->cleanupModalSessionsNeeded) { + d->cleanupModalSessions(); + if (d->currentModalSession() != session) + { + d->interrupt = true; + break; + } + } + } + if (!d->interrupt && session == d->currentModalSessionCached) { // Someone called [NSApp stopModal:] from outside the event // dispatcher (e.g to stop a native dialog). But that call wrongly stopped