Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qeventdispatcher_mac.mm

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9191#ifndef QT_NO_THREAD
    9292#  include "qmutex.h"
     93#endif
    9394
    9495QT_BEGIN_NAMESPACE
    9596
    9697QT_USE_NAMESPACE
    97 #endif
    9898
    9999/*****************************************************************************
     
    493493        case NSOtherMouseUp:     
    494494        case NSOtherMouseDragged:
     495#ifndef QT_NO_GESTURES
    495496#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
    496497        case NSEventTypeGesture: // touch events
     
    501502        case NSEventTypeEndGesture:
    502503#endif
     504#endif // QT_NO_GESTURES
    503505            result    = true;
    504506        break;
     
    549551    Q_D(QEventDispatcherMac);
    550552    d->interrupt = false;
     553
     554#ifdef QT_MAC_USE_COCOA
     555    bool interruptLater = false;
     556    QtMacInterruptDispatcherHelp::cancelInterruptLater();
     557#endif
     558
    551559    // In case we end up recursing while we now process events, make sure
    552560    // that we send remaining posted Qt events before this call returns:
     
    563571        NSEvent* event = 0;
    564572
    565         // If Qt is used as a plugin, or just added into a native cocoa
    566         // application, we should not run or stop NSApplication;
    567         // This will be done from outside Qt.
    568         // And if processEvents is called manually (rather than from QEventLoop), we
    569         // cannot enter a tight loop and block the call, but instead return after one flush:
    570         bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
    571         bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec;
     573        // First, send all previously excluded input events, if any:
     574        if (!(flags & QEventLoop::ExcludeUserInputEvents)) {
     575            while (!d->queuedUserInputEvents.isEmpty()) {
     576                event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
     577                if (!filterEvent(event)) {
     578                    qt_mac_send_event(flags, event, 0);
     579                    retVal = true;
     580                }
     581                [event release];
     582            }
     583        }
     584
     585        // If Qt is used as a plugin, or as an extension in a native cocoa
     586        // application, we should not run or stop NSApplication; This will be
     587        // done from the application itself. And if processEvents is called
     588        // manually (rather than from a QEventLoop), we cannot enter a tight
     589        // loop and block this call, but instead we need to return after one flush:
     590        const bool canExec_3rdParty = d->nsAppRunCalledByQt || ![NSApp isRunning];
     591        const bool canExec_Qt = flags & QEventLoop::DialogExec || flags & QEventLoop::EventLoopExec;
    572592
    573593        if (canExec_Qt && canExec_3rdParty) {
    574594            // We can use exec-mode, meaning that we can stay in a tight loop until
    575             // interrupted. This is mostly an optimization, but it also allow us
    576             // to use [NSApp run], which is the recommended way of running applications
    577             // in cocoa. [NSApp run] should be called at least once for any cocoa app.
     595            // interrupted. This is mostly an optimization, but it allow us to use
     596            // [NSApp run], which is the normal code path for cocoa applications.
    578597            if (NSModalSession session = d->currentModalSession()) {
    579598                QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
    580599                while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
    581600                    qt_mac_waitForMoreModalSessionEvents();
     601
    582602                if (!d->interrupt && session == d->currentModalSessionCached) {
    583                     // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event
     603                    // Someone called [NSApp stopModal:] from outside the event
    584604                    // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
    585605                    // 'session' as well. As a result, we need to restart all internal sessions:
     
    592612            }
    593613            retVal = true;
    594         } else do {
    595             // INVARIANT: We cannot block the thread (and run in a tight loop).
     614        } else {
     615            // We cannot block the thread (and run in a tight loop).
    596616            // Instead we will process all current pending events and return.
    597             bool mustRelease = false;
    598 
    599             if (!(flags & QEventLoop::ExcludeUserInputEvents) && !d->queuedUserInputEvents.isEmpty()) {
    600                 // Process a pending user input event
    601                 mustRelease = true;
    602                 event = static_cast<NSEvent *>(d->queuedUserInputEvents.takeFirst());
    603             } else {
    604                 if (NSModalSession session = d->currentModalSession()) {
    605                     if (flags & QEventLoop::WaitForMoreEvents)
    606                         qt_mac_waitForMoreModalSessionEvents();
    607                     NSInteger status = [NSApp runModalSession:session];
    608                     if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
    609                         // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event
    610                         // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
    611                         // 'session' as well. As a result, we need to restart all internal sessions:
    612                         d->temporarilyStopAllModalSessions();
    613                     }
    614                     retVal = true;
    615                     break;
    616                 } else {
    617                     event = [NSApp nextEventMatchingMask:NSAnyEventMask
    618                         untilDate:nil
    619                         inMode:NSDefaultRunLoopMode
    620                         dequeue: YES];
    621 
    622                     if (event != nil) {
    623                         if (flags & QEventLoop::ExcludeUserInputEvents) {
    624                             if (IsMouseOrKeyEvent(event)) {
    625                                 // retain event here?
    626                                 [event retain];
    627                                 d->queuedUserInputEvents.append(event);
    628                                 continue;
    629                             }
     617            d->ensureNSAppInitialized();
     618            if (NSModalSession session = d->currentModalSession()) {
     619                if (flags & QEventLoop::WaitForMoreEvents)
     620                    qt_mac_waitForMoreModalSessionEvents();
     621                NSInteger status = [NSApp runModalSession:session];
     622                if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
     623                    // INVARIANT: Someone called [NSApp stopModal:] from outside the event
     624                    // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
     625                    // 'session' as well. As a result, we need to restart all internal sessions:
     626                    d->temporarilyStopAllModalSessions();
     627                }
     628                retVal = true;
     629            } else do {
     630                event = [NSApp nextEventMatchingMask:NSAnyEventMask
     631                    untilDate:nil
     632                    inMode:NSDefaultRunLoopMode
     633                    dequeue: YES];
     634
     635                if (event) {
     636                    if (flags & QEventLoop::ExcludeUserInputEvents) {
     637                        if (IsMouseOrKeyEvent(event)) {
     638                            [event retain];
     639                            d->queuedUserInputEvents.append(event);
     640                            continue;
    630641                        }
    631642                    }
     643                    if (!filterEvent(event) && qt_mac_send_event(flags, event, 0))
     644                        retVal = true;
    632645                }
    633             }
    634             if (event) {
    635                 if (!filterEvent(event) && qt_mac_send_event(flags, event, 0))
    636                     retVal = true;
    637                 if (mustRelease)
    638                     [event release];
    639             }
    640         } while(!d->interrupt && event != nil);
    641 
     646            } while (!d->interrupt && event != nil);
     647
     648            // Since the window that holds modality might have changed while processing
     649            // events, we we need to interrupt when we return back the previous process
     650            // event recursion to ensure that we spin the correct modal session.
     651            // We do the interruptLater at the end of the function to ensure that we don't
     652            // disturb the 'wait for more events' below (as deleteLater will post an event):
     653            interruptLater = true;
     654        }
    642655#else
    643656        do {
     
    691704    }
    692705
     706    // If we're interrupted, we need to interrupt the _current_
     707    // recursion as well to check if it is  still supposed to be
     708    // executing. This way we wind down the stack until we land
     709    // on a recursion that again calls processEvents (typically
     710    // from QEventLoop), and set interrupt to false:
     711    if (d->interrupt)
     712        interrupt();
     713
    693714#ifdef QT_MAC_USE_COCOA
    694     // In case we _now_ process events using [NSApp run], we need to stop it to
    695     // ensure that:
    696     //    1. the QEventLoop that called us is still executing, or
    697     //    2. we have a modal session that needs to be spun instead.
    698     // In case this is a plain call to processEvents (perhaps from a loop)
    699     // from the application (rather than from a QEventLoop), we delay the
    700     // interrupting until we/ actually enter a lower loop level (hence the
    701     // deffered delete of the object below):
    702     QtMacInterruptDispatcherHelp::interruptLater();
    703 #endif
    704 
    705     if (d->interrupt) {
    706         // We should continue to leave all recursion to processEvents until
    707         // processEvents is called again (e.g. from a QEventLoop that
    708         // was not yet told to quit:
    709         interrupt();
    710     }
     715    if (interruptLater)
     716        QtMacInterruptDispatcherHelp::interruptLater();
     717#endif
    711718
    712719    return retVal;
     
    738745MacTimerHash QEventDispatcherMacPrivate::macTimerHash;
    739746bool QEventDispatcherMacPrivate::blockSendPostedEvents = false;
     747bool QEventDispatcherMacPrivate::interrupt = false;
    740748
    741749#ifdef QT_MAC_USE_COCOA
     
    743751bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
    744752bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
     753bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false;
    745754NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0;
    746755
    747 int QEventDispatcherMacPrivate::activeModalSessionCount()
    748 {
    749     // Returns the number of modal sessions created
    750     // (and not just pushed onto the stack, pending to be created)
    751     int count = 0;
    752     for (int i=cocoaModalSessionStack.size()-1; i>=0; --i) {
    753         QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
    754         if (info.session)
    755             ++count;
    756     }
    757     return count;
     756void QEventDispatcherMacPrivate::ensureNSAppInitialized()
     757{
     758    // Some elements in Cocoa require NSApplication to be running before
     759    // they get fully initialized, in particular the menu bar. This
     760    // function is intended for cases where a dialog is told to execute before
     761    // QApplication::exec is called, or the application spins the events loop
     762    // manually rather than calling QApplication:exec.
     763    // The function makes sure that NSApplication starts running, but stops
     764    // it again as soon as the send posted events callback is called. That way
     765    // we let Cocoa finish the initialization it seems to need. We'll only
     766    // apply this trick at most once for any application, and we avoid doing it
     767    // for the common case where main just starts QApplication::exec.
     768    if (nsAppRunCalledByQt || [NSApp isRunning])
     769        return;
     770    nsAppRunCalledByQt = true;
     771    QBoolBlocker block1(interrupt, true);
     772    QBoolBlocker block2(currentExecIsNSAppRun, true);
     773    [NSApp run];
    758774}
    759775
    760776void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
    761777{
    762     // Stop all created modal session, and as such, make then
    763     // pending again. The next call to currentModalSession will
    764     // recreate the session on top again:
     778    // Flush, and Stop, all created modal session, and as
     779    // such, make them pending again. The next call to
     780    // currentModalSession will recreate them again. The
     781    // reason to stop all session like this is that otherwise
     782    // a call [NSApp stop] would not stop NSApp, but rather
     783    // the current modal session. So if we need to stop NSApp
     784    // we need to stop all the modal session first. To avoid changing
     785    // the stacking order of the windows while doing so, we put
     786    // up a block that is used in QCocoaWindow and QCocoaPanel:
    765787    int stackSize = cocoaModalSessionStack.size();
    766     for (int i=stackSize-1; i>=0; --i) {
     788    for (int i=0; i<stackSize; ++i) {
    767789        QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
    768790        if (info.session) {
     
    783805    if (cocoaModalSessionStack.isEmpty())
    784806        return 0;
    785 
    786     // Since this code will end up calling our Qt event handler
    787     // (also from beginModalSessionForWindow), we need to block
    788     // that to avoid side effects of events beeing delivered:
    789     QBoolBlocker block(blockSendPostedEvents, true);
    790 
    791     if (![NSApp isRunning]) {
    792         // Sadly, we need to introduce this little event flush
    793         // to stop dialogs from blinking/poping in front if a
    794         // modal session restart was needed:
    795         while (NSEvent *event = [NSApp nextEventMatchingMask:0
    796                 untilDate:nil
    797                 inMode:NSDefaultRunLoopMode
    798                 dequeue: YES]) {
    799             qt_mac_send_event(0, event, 0);
    800         }
    801     }
    802807
    803808    int sessionCount = cocoaModalSessionStack.size();
     
    813818            if (!window)
    814819                continue;
     820
     821            ensureNSAppInitialized();
     822            QBoolBlocker block1(blockSendPostedEvents, true);
     823            info.nswindow = window;
     824            [(NSWindow*) info.nswindow retain];
     825            int levelBeforeEnterModal = [window level];
    815826            info.session = [NSApp beginModalSessionForWindow:window];
     827            // Make sure we don't stack the window lower that it was before
     828            // entering modal, in case it e.g. had the stays-on-top flag set:
     829            if (levelBeforeEnterModal > [window level])
     830                [window setLevel:levelBeforeEnterModal];
    816831        }
    817832        currentModalSessionCached = info.session;
    818     }
    819 
     833        cleanupModalSessionsNeeded = false;
     834    }
    820835    return currentModalSessionCached;
    821836}
     
    830845        if (window && [window isKindOfClass:[NSPanel class]]) {
    831846            [static_cast<NSPanel *>(window) setWorksWhenModal:worksWhenModal];
    832             if (worksWhenModal && dialogs[i]->isVisible()){
     847            if (worksWhenModal && [window isVisible]){
    833848                [window orderFront:window];
    834849            }
     
    842857    // active. And make the dialog children of
    843858    // the previous modal dialog unactive again:
     859    QMacCocoaAutoReleasePool pool;
    844860    int size = cocoaModalSessionStack.size();
    845861    if (size > 0){
     
    853869}
    854870
     871void QEventDispatcherMacPrivate::cleanupModalSessions()
     872{
     873    // Go through the list of modal sessions, and end those
     874    // that no longer has a widget assosiated; no widget means
     875    // the the session has logically ended. The reason we wait like
     876    // this to actually end the sessions for real (rather than at the
     877    // point they were marked as stopped), is that ending a session
     878    // when no other session runs below it on the stack will make cocoa
     879    // drop some events on the floor.
     880    QMacCocoaAutoReleasePool pool;
     881    int stackSize = cocoaModalSessionStack.size();
     882
     883    for (int i=stackSize-1; i>=0; --i) {
     884        QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
     885        if (info.widget) {
     886            // This session has a widget, and is therefore not marked
     887            // as stopped. So just make it current. There might still be other
     888            // stopped sessions on the stack, but those will be stopped on
     889            // a later "cleanup" call.
     890            currentModalSessionCached = info.session;
     891            break;
     892        }
     893        cocoaModalSessionStack.remove(i);
     894        currentModalSessionCached = 0;
     895        if (info.session) {
     896            [NSApp endModalSession:info.session];
     897            [(NSWindow *)info.nswindow release];
     898        }
     899    }
     900
     901    updateChildrenWorksWhenModal();
     902    cleanupModalSessionsNeeded = false;
     903}
     904
    855905void QEventDispatcherMacPrivate::beginModalSession(QWidget *widget)
    856906{
     
    861911    // currentModalSession). A QCocoaModalSessionInfo is considered pending to be stopped if
    862912    // the widget pointer is zero, and the session pointer is non-zero (it will be fully
    863     // stopped in endModalSession().
    864     QCocoaModalSessionInfo info = {widget, 0};
     913    // stopped in cleanupModalSessions()).
     914    QCocoaModalSessionInfo info = {widget, 0, 0};
    865915    cocoaModalSessionStack.push(info);
    866916    updateChildrenWorksWhenModal();
     
    878928    for (int i=stackSize-1; i>=0; --i) {
    879929        QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
    880         if (info.widget == widget)
     930        if (info.widget == widget) {
    881931            info.widget = 0;
    882     }
    883 
    884     // Now we stop, and remove, all sessions marked as pending
    885     // to be stopped on _top_ of the stack, if any:
    886     bool needToInterruptEventDispatcher = false;
    887     bool needToUpdateChildrenWorksWhenModal = false;
    888 
    889     for (int i=stackSize-1; i>=0; --i) {
    890         QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
    891         if (info.widget)
    892             break;
    893         cocoaModalSessionStack.remove(i);
    894         needToUpdateChildrenWorksWhenModal = true;
    895         currentModalSessionCached = 0;
    896         if (info.session) {
    897             [NSApp endModalSession:info.session];
    898             needToInterruptEventDispatcher = true;
    899         }
    900     }
    901 
    902     if (needToUpdateChildrenWorksWhenModal)
    903         updateChildrenWorksWhenModal();
    904     if (needToInterruptEventDispatcher)
    905         QEventDispatcherMac::instance()->interrupt();
     932            if (i == stackSize-1) {
     933                // The top sessions ended. Interrupt the event dispatcher
     934                // to start spinning the correct session immidiatly:
     935                currentModalSessionCached = 0;
     936                cleanupModalSessionsNeeded = true;
     937                QEventDispatcherMac::instance()->interrupt();
     938            }
     939        }
     940    }
    906941}
    907942
     
    909944
    910945QEventDispatcherMacPrivate::QEventDispatcherMacPrivate()
    911     : interrupt(false)
    912946{
    913947}
     
    9681002inline static void processPostedEvents(QEventDispatcherMacPrivate *const d, const bool blockSendPostedEvents)
    9691003{
    970     if (blockSendPostedEvents || d->interrupt) {
     1004    if (blockSendPostedEvents) {
     1005        // We're told to not send posted events (because the event dispatcher
     1006        // is currently working on setting up the correct session to run). But
     1007        // we still need to make sure that we don't fall asleep until pending events
     1008        // are sendt, so we just signal this need, and return:
    9711009        CFRunLoopSourceSignal(d->postedEventsSource);
    972     } else {
    973         if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) {
    974             d->lastSerial = d->serialNumber;
    975             QApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
    976         }
     1010        return;
     1011    }
     1012
     1013#ifdef QT_MAC_USE_COCOA
     1014    if (d->cleanupModalSessionsNeeded)
     1015        d->cleanupModalSessions();
     1016#endif
     1017
     1018    if (d->interrupt) {
     1019#ifdef QT_MAC_USE_COCOA
     1020        if (d->currentExecIsNSAppRun) {
     1021            // The event dispatcher has been interrupted. But since
     1022            // [NSApplication run] is running the event loop, we
     1023            // delayed stopping it until now (to let cocoa process
     1024            // pending cocoa events first).
     1025            if (d->currentModalSessionCached)
     1026                d->temporarilyStopAllModalSessions();
     1027            [NSApp stop:NSApp];
     1028            d->cancelWaitForMoreEvents();
     1029        }
     1030#endif
     1031        return;
     1032    }
     1033
     1034    if (!d->threadData->canWait || (d->serialNumber != d->lastSerial)) {
     1035        d->lastSerial = d->serialNumber;
     1036        QApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
    9771037    }
    9781038}
     
    9841044    Q_UNUSED(ref);
    9851045    Q_UNUSED(activity);
     1046#ifdef QT_MAC_USE_COCOA
     1047    QApplicationPrivate::qt_initAfterNSAppStarted();
     1048#endif
    9861049    processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
    9871050}
     
    9911054    processPostedEvents(static_cast<QEventDispatcherMacPrivate *>(info), blockSendPostedEvents);
    9921055}
     1056
     1057#ifdef QT_MAC_USE_COCOA
     1058void QEventDispatcherMacPrivate::cancelWaitForMoreEvents()
     1059{
     1060    // In case the event dispatcher is waiting for more
     1061    // events somewhere, we post a dummy event to wake it up:
     1062    QMacCocoaAutoReleasePool pool;
     1063    [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
     1064        modifierFlags:0 timestamp:0. windowNumber:0 context:0
     1065        subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
     1066}
     1067#endif
    9931068
    9941069void QEventDispatcherMac::interrupt()
     
    10011076    CFRunLoopStop(mainRunLoop());
    10021077#else
    1003     QMacCocoaAutoReleasePool pool;
    1004     // In case we wait for more events inside
    1005     // processEvents (or NSApp run), post a dummy to wake it up:
    1006     static const short NSAppShouldStopForQt = SHRT_MAX;
    1007     [NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
    1008         modifierFlags:0 timestamp:0. windowNumber:0 context:0
    1009         subtype:NSAppShouldStopForQt data1:0 data2:0] atStart:NO];
    1010 
    1011     if (d->activeModalSessionCount() == 0) {
    1012         // We should only stop NSApp if we actually started it (and
    1013         // not some 3rd party application, e.g. if we are a plugin).
    1014         if (d->nsAppRunCalledByQt)
    1015             [NSApp stop:NSApp];
    1016     }
     1078    // We do nothing more here than setting d->interrupt = true, and
     1079    // poke the event loop if it is sleeping. Actually stopping
     1080    // NSApp, or the current modal session, is done inside the send
     1081    // posted events callback. We do this to ensure that all current pending
     1082    // cocoa events gets delivered before we stop. Otherwise, if we now stop
     1083    // the last event loop recursion, cocoa will just drop pending posted
     1084    // events on the floor before we get a chance to reestablish a new session.
     1085    d->cancelWaitForMoreEvents();
    10171086#endif
    10181087}
     
    10551124}
    10561125
    1057 /////////////////////////////////////////////////////////////////////////////
    1058 
    10591126#ifdef QT_MAC_USE_COCOA
    10601127
     
    10631130QtMacInterruptDispatcherHelp::QtMacInterruptDispatcherHelp() : cancelled(false)
    10641131{
    1065     // This is the whole point of encapsulation this code
    1066     // inside a class; we can make the code (inside destructor)
    1067     // execute on lower loop level:
     1132    // The whole point of this class is that we enable a way to interrupt
     1133    // the event dispatcher when returning back to a lower recursion level
     1134    // than where interruptLater was called. This is needed to detect if
     1135    // [NSApp run] should still be running at the recursion level it is at.
     1136    // Since the interrupt is canceled if processEvents is called before
     1137    // this object gets deleted, we also avoid interrupting unnecessary.
    10681138    deleteLater();
    10691139}
     
    10731143    if (cancelled)
    10741144        return;
    1075 
    10761145    instance = 0;
    1077 
    1078     if (QEventDispatcherMacPrivate::currentExecIsNSAppRun) {
    1079         int activeCount = QEventDispatcherMacPrivate::activeModalSessionCount();
    1080         if (activeCount > 0) {
    1081             // The problem we now have hit: [NSApp stop] will not stop NSApp
    1082             // if a session is active; it will stop the session instead.
    1083             // So to stop NSApp, we need to temporarily stop all the
    1084             // sessions, then stop NSApp, then restart the session on top again.
    1085             // We need to do this to ensure that we're not stuck inside
    1086             // [NSApp run] when we really should be running a modal session:
    1087             QEventDispatcherMacPrivate::temporarilyStopAllModalSessions();
    1088         }
    1089     }
    1090     // Always interrupt once more in case the modal session stack changed
    1091     // while processEvents was called manually from within the application:
    10921146    QEventDispatcherMac::instance()->interrupt();
    10931147}
    10941148
    1095 void QtMacInterruptDispatcherHelp::interruptLater() {
    1096     if (instance) {
    1097         instance->cancelled = true;
    1098         delete instance;
    1099     }
     1149void QtMacInterruptDispatcherHelp::cancelInterruptLater()
     1150{
     1151    if (!instance)
     1152        return;
     1153    instance->cancelled = true;
     1154    delete instance;
     1155    instance = 0;
     1156}
     1157
     1158void QtMacInterruptDispatcherHelp::interruptLater()
     1159{
     1160    cancelInterruptLater();
    11001161    instance = new QtMacInterruptDispatcherHelp;
    11011162}
     
    11041165
    11051166QT_END_NAMESPACE
     1167
Note: See TracChangeset for help on using the changeset viewer.