From afbe855296cad110275541a1c660f8f005122a42 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Thu, 20 Apr 2006 03:11:47 +0000 Subject: 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 --- src/Fl.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Fl.cxx b/src/Fl.cxx index 17967a783..accd7c6b0 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -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); -- cgit v1.2.3