Changeset 80


Ignore:
Timestamp:
Apr 6, 2006, 9:32:24 PM (19 years ago)
Author:
dmik
Message:

Fixed a trap after issuing exit() if a QAplication instance has been created on the stack in main() (see ticket:10 for more info).

File:
1 edited

Legend:

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

    r8 r80  
    29332933const uint QFontCache::min_cost = 4*1024; // 4mb
    29342934
     2935#if defined (Q_OS_OS2)
     2936
     2937// On OS/2, destructors of static objects in a DLL cannot use objects created
     2938// on the stack of the main thread when the application is being abnormally
     2939// terminated (exit(), DosExit(), DosKillProcess(), etc), because at a time when
     2940// these static destructors are called (from _DLL_InitTerm on most compilers,
     2941// including GCC and IBM VAC) the stack is most likely reused  by the DLL
     2942// termination code. Since QFontCache is a child of QApplication (which is
     2943// usually created as a local object inside the main() function) and wants to
     2944// use its parent during destruction, this becomes a real problem and causes a
     2945// guaranteed application trap during abnormal termination. The workaround is to
     2946// use atexit() instead. Note that this will only work for the exit() case
     2947// (on DosExit() or DosKillProcess(), the stdlib's exit list is not processed).
     2948
     2949static void cleanupFontCache()
     2950{
     2951    if (QFontCache::instance != 0)
     2952        delete QFontCache::instance;
     2953}
     2954
     2955#else
    29352956static QSingleCleanupHandler<QFontCache> cleanup_fontcache;
    2936 
     2957#endif
    29372958
    29382959QFontCache::QFontCache()
     
    29422963    Q_ASSERT( instance == 0 );
    29432964    instance = this;
     2965#if defined (Q_OS_OS2)
     2966    atexit( cleanupFontCache );
     2967#else
    29442968    cleanup_fontcache.set( &instance );
     2969#endif   
    29452970}
    29462971
Note: See TracChangeset for help on using the changeset viewer.