]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed memory leak introduced by dynamic wxMimeTypesManagerImpl creation (rev. 1.44...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Jun 2006 17:01:46 +0000 (17:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 5 Jun 2006 17:01:46 +0000 (17:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/mimetype.h
src/common/mimecmn.cpp

index 5265a82abd3d795bcf223c4bf6a494a0677d1bfe..59369ba56518bdb2a91f411b15546afb4f16c6a6 100644 (file)
@@ -356,8 +356,8 @@ public:
 
     virtual wxMimeTypesManagerImpl *CreateMimeTypesManagerImpl();
 
-    static void SetFactory( wxMimeTypesManagerFactory *factory );
-    static wxMimeTypesManagerFactory *GetFactory();
+    static void Set( wxMimeTypesManagerFactory *factory );
+    static wxMimeTypesManagerFactory *Get();
     
 private:
     static wxMimeTypesManagerFactory *m_factory;
index 27d4b8d4295cc0f0fa1f018967f4053dd5aa5581..680d57fc28843f735cde1ab9f715634d45022352 100644 (file)
@@ -453,28 +453,27 @@ bool wxFileType::SetDefaultIcon(const wxString& cmd, int index)
 #endif
 }
 
-//----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 // wxMimeTypesManagerFactory
-//----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
 
 wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::m_factory = NULL;
 
 /* static */
-void wxMimeTypesManagerFactory::SetFactory( wxMimeTypesManagerFactory *factory )
+void wxMimeTypesManagerFactory::Set(wxMimeTypesManagerFactory *factory)
 {
-    if (wxMimeTypesManagerFactory::m_factory)
-        delete wxMimeTypesManagerFactory::m_factory;
+    delete m_factory;
 
-    wxMimeTypesManagerFactory::m_factory = factory;
+    m_factory = factory;
 }
 
 /* static */
-wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::GetFactory()
+wxMimeTypesManagerFactory *wxMimeTypesManagerFactory::Get()
 {
-    if (!wxMimeTypesManagerFactory::m_factory)
-        wxMimeTypesManagerFactory::m_factory = new wxMimeTypesManagerFactory;
+    if ( !m_factory )
+        m_factory = new wxMimeTypesManagerFactory;
 
-    return wxMimeTypesManagerFactory::m_factory;
+    return m_factory;
 }
 
 wxMimeTypesManagerImpl *wxMimeTypesManagerFactory::CreateMimeTypesManagerImpl()
@@ -489,7 +488,7 @@ wxMimeTypesManagerImpl *wxMimeTypesManagerFactory::CreateMimeTypesManagerImpl()
 void wxMimeTypesManager::EnsureImpl()
 {
     if ( !m_impl )
-        m_impl = wxMimeTypesManagerFactory::GetFactory()->CreateMimeTypesManagerImpl();
+        m_impl = wxMimeTypesManagerFactory::Get()->CreateMimeTypesManagerImpl();
 }
 
 bool wxMimeTypesManager::IsOfType(const wxString& mimeType,
@@ -673,10 +672,12 @@ class wxMimeTypeCmnModule: public wxModule
 {
 public:
     wxMimeTypeCmnModule() : wxModule() { }
+
     virtual bool OnInit() { return true; }
     virtual void OnExit()
     {
-        // this avoids false memory leak allerts:
+        wxMimeTypesManagerFactory::Set(NULL);
+
         if ( gs_mimeTypesManager.m_impl != NULL )
         {
             delete gs_mimeTypesManager.m_impl;