]> git.saurik.com Git - wxWidgets.git/commitdiff
fix memory leak of FrameSite (see #3935)
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 13 Jan 2009 23:04:03 +0000 (23:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 13 Jan 2009 23:04:03 +0000 (23:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/ole/activex.h
src/msw/ole/activex.cpp

index dbdcf0741a2dc1fd001bd9d37adb7eb2bd41fa86..9cc999a43765fb8dbb3ca68f0cb4f713780402d5 100644 (file)
@@ -155,6 +155,7 @@ protected:
     friend class FrameSite;
     friend class wxActiveXEvents;
 
     friend class FrameSite;
     friend class wxActiveXEvents;
 
+    FrameSite *m_frameSite;
     wxAutoIDispatch            m_Dispatch;
     wxAutoIOleClientSite      m_clientSite;
     wxAutoIUnknown         m_ActiveX;
     wxAutoIDispatch            m_Dispatch;
     wxAutoIOleClientSite      m_clientSite;
     wxAutoIUnknown         m_ActiveX;
index 58a4c2bf68770bd1028347ccc2bea7cb996c9656..0f3ccfa75040e1c84dd85c4bd2b4af3f1fc73094 100644 (file)
@@ -829,6 +829,10 @@ wxActiveXContainer::~wxActiveXContainer()
         m_oleObject->Close(OLECLOSE_NOSAVE);
         m_oleObject->SetClientSite(NULL);
     }
         m_oleObject->Close(OLECLOSE_NOSAVE);
         m_oleObject->SetClientSite(NULL);
     }
+
+    // m_clientSite uses m_frameSite so destroy it first
+    m_clientSite.Free();
+    delete m_frameSite;
 }
 
 // VZ: we might want to really report an error instead of just asserting here
 }
 
 // VZ: we might want to really report an error instead of just asserting here
@@ -855,13 +859,13 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
     CHECK_HR(hret);
 
     // FrameSite
     CHECK_HR(hret);
 
     // FrameSite
-    FrameSite *frame = new FrameSite(m_realparent, this);
+    m_frameSite = new FrameSite(m_realparent, this);
     // oleClientSite
     hret = m_clientSite.QueryInterface(
     // oleClientSite
     hret = m_clientSite.QueryInterface(
-        IID_IOleClientSite, (IDispatch *) frame);
+        IID_IOleClientSite, (IDispatch *) m_frameSite);
     CHECK_HR(hret);
     // adviseSink
     CHECK_HR(hret);
     // adviseSink
-    wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) frame);
+    wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite);
     wxASSERT(adviseSink.Ok());
 
     // Get Dispatch interface
     wxASSERT(adviseSink.Ok());
 
     // Get Dispatch interface
@@ -951,7 +955,7 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
                 CHECK_HR(hret);
 
                 IDispatch* disp;
                 CHECK_HR(hret);
 
                 IDispatch* disp;
-                frame->QueryInterface(IID_IDispatch, (void**)&disp);
+                m_frameSite->QueryInterface(IID_IDispatch, (void**)&disp);
                 hret = cp->Advise(new wxActiveXEvents(this, ta->guid),
                                   &adviseCookie);
                 CHECK_HR(hret);
                 hret = cp->Advise(new wxActiveXEvents(this, ta->guid),
                                   &adviseCookie);
                 CHECK_HR(hret);