]> git.saurik.com Git - wxWidgets.git/commitdiff
shut down GDI+ from a module instead of doing it during static object destruction...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 19 Sep 2007 01:02:16 +0000 (01:02 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 19 Sep 2007 01:02:16 +0000 (01:02 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48778 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/graphics.cpp

index bda43979a70c9a988ce2a67aa3fb38c376a42693..f6eb219ca72ac01acbcd6946c3f24d2c733b995a 100644 (file)
@@ -1286,6 +1286,7 @@ protected :
     void EnsureIsLoaded();
     void Load();
     void Unload();
     void EnsureIsLoaded();
     void Load();
     void Unload();
+    friend class wxGDIPlusRendererModule;
 
 private :
     bool m_loaded;
 
 private :
     bool m_loaded;
@@ -1326,7 +1327,11 @@ void wxGDIPlusRenderer::Load()
 void wxGDIPlusRenderer::Unload()
 {
     if ( m_gditoken )
 void wxGDIPlusRenderer::Unload()
 {
     if ( m_gditoken )
+    {
         GdiplusShutdown(m_gditoken);
         GdiplusShutdown(m_gditoken);
+        m_gditoken = NULL;
+    }
+    m_loaded = false;
 }
 
 wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxWindowDC& dc)
 }
 
 wxGraphicsContext * wxGDIPlusRenderer::CreateContext( const wxWindowDC& dc)
@@ -1458,4 +1463,17 @@ wxGraphicsFont wxGDIPlusRenderer::CreateFont( const wxFont &font , const wxColou
         return wxNullGraphicsFont;
 }
 
         return wxNullGraphicsFont;
 }
 
+// Shutdown GDI+ at app exit, before possible dll unload
+class wxGDIPlusRendererModule : public wxModule
+{
+public:
+    virtual bool OnInit() { return true; }
+    virtual void OnExit() { gs_GDIPlusRenderer.Unload(); }
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxGDIPlusRendererModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusRendererModule, wxModule)
+
 #endif  // wxUSE_GRAPHICS_CONTEXT
 #endif  // wxUSE_GRAPHICS_CONTEXT