src/gui/kernel/qeventdispatcher_mac.mm
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   569             // in cocoa. [NSApp run] should be called at least once for any cocoa app.
   569             // in cocoa. [NSApp run] should be called at least once for any cocoa app.
   570             if (NSModalSession session = d->currentModalSession()) {
   570             if (NSModalSession session = d->currentModalSession()) {
   571                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
   571                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
   572                 while (!d->interrupt && [NSApp runModalSession:session] == NSRunContinuesResponse)
   572                 while (!d->interrupt && [NSApp runModalSession:session] == NSRunContinuesResponse)
   573                     qt_mac_waitForMoreModalSessionEvents();
   573                     qt_mac_waitForMoreModalSessionEvents();
       
   574                 if (!d->interrupt && session == d->currentModalSessionCached) {
       
   575                     // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event
       
   576                     // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
       
   577                     // 'session' as well. As a result, we need to restart all internal sessions:
       
   578                     d->temporarilyStopAllModalSessions();
       
   579                 }
   574             } else {
   580             } else {
   575                 d->nsAppRunCalledByQt = true;
   581                 d->nsAppRunCalledByQt = true;
   576                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, true);
   582                 QBoolBlocker execGuard(d->currentExecIsNSAppRun, true);
   577                 [NSApp run];
   583                 [NSApp run];
   578             }
   584             }
   588                 event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
   594                 event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
   589             } else {
   595             } else {
   590                 if (NSModalSession session = d->currentModalSession()) {
   596                 if (NSModalSession session = d->currentModalSession()) {
   591                     if (flags & QEventLoop::WaitForMoreEvents)
   597                     if (flags & QEventLoop::WaitForMoreEvents)
   592                         qt_mac_waitForMoreModalSessionEvents();
   598                         qt_mac_waitForMoreModalSessionEvents();
   593                     [NSApp runModalSession:session];
   599                     NSInteger status = [NSApp runModalSession:session];
       
   600                     if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
       
   601                         // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event
       
   602                         // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
       
   603                         // 'session' as well. As a result, we need to restart all internal sessions:
       
   604                         d->temporarilyStopAllModalSessions();
       
   605                     }
   594                     retVal = true;
   606                     retVal = true;
   595                     break;
   607                     break;
   596                 } else {
   608                 } else {
   597                     event = [NSApp nextEventMatchingMask:NSAnyEventMask
   609                     event = [NSApp nextEventMatchingMask:NSAnyEventMask
   598                         untilDate:nil
   610                         untilDate:nil