STR #1231: moved clearing of resources out of Fl::run() into a static class destructor. Although this should work, I was unable to test this (no Windows machine at this time). Also, since the order in which static destructors are called is undefined, this code can still lead to a crash if the main window was alos statically allocate in global space. Suggestions welcome.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5004 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2006-04-20 03:11:47 +00:00
parent 9460fcc375
commit afbe855296
1 changed files with 16 additions and 7 deletions

View File

@ -355,16 +355,25 @@ double Fl::wait(double time_to_wait) {
int Fl::run() {
while (Fl_X::first) wait(FOREVER);
#ifdef WIN32
fl_free_fonts(); // do some WIN32 cleanup
fl_cleanup_pens();
OleUninitialize();
fl_brush_action(1);
fl_cleanup_dc_list();
#endif
return 0;
}
#ifdef WIN32
class Fl_Win32_At_Exit {
Fl_Win32_At_Exit() { }
~Fl_Win32_At_Exit() {
fl_free_fonts(); // do some WIN32 cleanup
fl_cleanup_pens();
OleUninitialize();
fl_brush_action(1);
fl_cleanup_dc_list();
}
};
static Fl_Win32_At_Exit win32_at_exit;
#endif
int Fl::wait() {
if (!Fl_X::first) return 0;
wait(FOREVER);