 diff -ruN qt-4.8.6/src/gui/kernel/qeventdispatcher_mac.mm qt-4.8.6-new/src/gui/kernel/qeventdispatcher_mac.mm
 --- qt-4.8.6/src/gui/kernel/qeventdispatcher_mac.mm	2014-04-10 08:37:12.000000000 -1000
-+++ qt-4.8.6-new/src/gui/kernel/qeventdispatcher_mac.mm	2015-01-20 12:57:35.000000000 -1000
++++ qt-4.8.6-new/src/gui/kernel/qeventdispatcher_mac.mm	2015-01-20 14:42:34.000000000 -1000
 @@ -558,7 +558,6 @@
  
      // In case we end up recursing while we now process events, make sure

                         // INVARIANT: Someone called [NSApp stopModal:] from outside the event
                         // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
                         // 'session' as well. As a result, we need to restart all internal sessions:
@@ -823,6 +858,7 @@
         if (info.session) {
             [NSApp endModalSession:info.session];
             info.session = 0;

 
                 if (!d->interrupt && session == d->currentModalSessionCached) {
                     // Someone called [NSApp stopModal:] from outside the event
@@ -609,6 +635,11 @@
                     // '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);
@@ -626,13 +657,26 @@
                     // to use cocoa's native way of running modal sessions:
                     if (flags & QEventLoop::WaitForMoreEvents)
                         qt_mac_waitForMoreModalSessionEvents();
