]> git.saurik.com Git - wxWidgets.git/commitdiff
free wxDCFactory::m_factory; also renamed SetDCFactory() to just Set()
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Nov 2007 21:11:00 +0000 (21:11 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 Nov 2007 21:11:00 +0000 (21:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50387 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dc.h
src/common/dcbase.cpp

index 1cd67be835df13b6d53541357244429ef3511e50..90e878d4b186041aeb8dce407cdda82ac51870de 100644 (file)
@@ -129,7 +129,7 @@ public:
     virtual wxDCImpl* CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data  ) = 0;
 #endif
 
-    static void SetDCFactory( wxDCFactory *factory );
+    static void Set(wxDCFactory *factory);
     static wxDCFactory *Get();
 
 private:
index 5e11a81ee5761ae9b1ba9fc7eb019258ac29830f..0989ecc110811d6899c734af1bf8112e376c0f85 100644 (file)
 
 #ifndef WX_PRECOMP
     #include "wx/math.h"
+    #include "wx/module.h"
 #endif
 
 #ifdef __WXMSW__
-#include "wx/msw/dcclient.h"
-#include "wx/msw/dcmemory.h"
-#include "wx/msw/dcscreen.h"
+    #include "wx/msw/dcclient.h"
+    #include "wx/msw/dcmemory.h"
+    #include "wx/msw/dcscreen.h"
 #endif
 
 #ifdef __WXGTK__
-#include "wx/gtk/dcclient.h"
-#include "wx/gtk/dcmemory.h"
-#include "wx/gtk/dcscreen.h"
+    #include "wx/gtk/dcclient.h"
+    #include "wx/gtk/dcmemory.h"
+    #include "wx/gtk/dcscreen.h"
 #endif
 
 #ifdef __WXMAC__
-#include "wx/mac/dcclient.h"
-#include "wx/mac/dcmemory.h"
-#include "wx/mac/dcscreen.h"
+    #include "wx/mac/dcclient.h"
+    #include "wx/mac/dcmemory.h"
+    #include "wx/mac/dcscreen.h"
 #endif
 
 #ifdef __WXX11__
-#include "wx/x11/dcclient.h"
-#include "wx/x11/dcmemory.h"
-#include "wx/x11/dcscreen.h"
+    #include "wx/x11/dcclient.h"
+    #include "wx/x11/dcmemory.h"
+    #include "wx/x11/dcscreen.h"
 #endif
 
 //----------------------------------------------------------------------------
 
 wxDCFactory *wxDCFactory::m_factory = NULL;
 
-void wxDCFactory::SetDCFactory( wxDCFactory *factory )
+void wxDCFactory::Set(wxDCFactory *factory)
 {
-    if (wxDCFactory::m_factory)
-        delete wxDCFactory::m_factory;
+    delete m_factory;
 
-    wxDCFactory::m_factory = factory;
+    m_factory = factory;
 }
 
 wxDCFactory *wxDCFactory::Get()
 {
-    if (!wxDCFactory::m_factory)
-        wxDCFactory::m_factory = new wxNativeDCFactory;
+    if ( !m_factory )
+        m_factory = new wxNativeDCFactory;
 
-    return wxDCFactory::m_factory;
+    return m_factory;
 }
 
+class wxDCFactoryCleanupModule : public wxModule
+{
+public:
+    virtual bool OnInit() { return true; }
+    virtual void OnExit() { wxDCFactory::Set(NULL); }
+
+private:
+    DECLARE_DYNAMIC_CLASS(wxDCFactoryCleanupModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxDCFactoryCleanupModule, wxModule)
+
 //-----------------------------------------------------------------------------
 // wxNativeDCFactory
 //-----------------------------------------------------------------------------