Changeset 180


Ignore:
Timestamp:
Mar 1, 2008, 4:42:34 PM (17 years ago)
Author:
dmik
Message:

kernel: Make sure that eventloop is cleaned up after all post-routines (that may still use some eventloop services such as timers) are called and that start timer requests are ignored after the eventloop has been cleaned up during application termination. This fixes assertions and crashes that might have happened at program termination otherwise.

Location:
trunk/src/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel/qapplication.cpp

    r174 r180  
    10261026#endif
    10271027
    1028     if ( eventloop )
    1029         eventloop->appClosingDown();
    10301028    if ( postRList ) {
    10311029        QVFuncList::Iterator it = postRList->begin();
     
    10821080    delete qt_dnd_manager;
    10831081#endif
     1082
     1083    // make sure eventloop is cleaned up after all post-routines and some object
     1084    // destructors (that may still use some eventloop services such as timers)
     1085    // are called. Note that this place is still not perfect as destructors of
     1086    // children of QApplication will be called (by the QObject dtor) after this
     1087    // method anyway and nothing prevents them from using e.g. timers.
     1088    if ( eventloop )
     1089        eventloop->appClosingDown();
    10841090
    10851091    qt_cleanup();
  • trunk/src/kernel/qeventloop_pm.cpp

    r177 r180  
    764764//  to properly destroy the window).
    765765
     766static bool timersCleanedUp = false;
     767
    766768static void cleanupTimers()                     // remove pending timers
    767769{
     770    timersCleanedUp = true;
     771
    768772#ifndef QT_PM_NO_DOSTIMERS
    769773    if ( !timerDict )               // no timers were used
     
    792796    timerDict = 0;
    793797    delete timerVec;
    794     timerVec  = 0;
     798    timerVec = 0;
    795799#endif // ifndef QT_PM_NO_DOSTIMERS
     800
     801    numZeroTimers = 0;
    796802}
    797803
     
    804810int qStartTimer( int interval, QObject *obj )
    805811{
     812    // ignore start timer requests after application termination has started
     813    Q_ASSERT( !timersCleanedUp );
     814    if ( timersCleanedUp )
     815        return 0;
     816
    806817    Q_ASSERT( obj );
    807818    if ( !obj || interval < 0 )
Note: See TracChangeset for help on using the changeset viewer.