From: Vadim Zeitlin Date: Tue, 13 Jan 2009 23:04:03 +0000 (+0000) Subject: fix memory leak of FrameSite (see #3935) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9b53796d59776a9510f70379e0d476c29c366489?ds=sidebyside fix memory leak of FrameSite (see #3935) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/msw/ole/activex.h b/include/wx/msw/ole/activex.h index dbdcf0741a..9cc999a437 100644 --- a/include/wx/msw/ole/activex.h +++ b/include/wx/msw/ole/activex.h @@ -155,6 +155,7 @@ protected: friend class FrameSite; friend class wxActiveXEvents; + FrameSite *m_frameSite; wxAutoIDispatch m_Dispatch; wxAutoIOleClientSite m_clientSite; wxAutoIUnknown m_ActiveX; diff --git a/src/msw/ole/activex.cpp b/src/msw/ole/activex.cpp index 58a4c2bf68..0f3ccfa750 100644 --- a/src/msw/ole/activex.cpp +++ b/src/msw/ole/activex.cpp @@ -829,6 +829,10 @@ wxActiveXContainer::~wxActiveXContainer() 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 @@ -855,13 +859,13 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk) CHECK_HR(hret); // FrameSite - FrameSite *frame = new FrameSite(m_realparent, this); + m_frameSite = new FrameSite(m_realparent, this); // oleClientSite hret = m_clientSite.QueryInterface( - IID_IOleClientSite, (IDispatch *) frame); + IID_IOleClientSite, (IDispatch *) m_frameSite); CHECK_HR(hret); // adviseSink - wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) frame); + wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite); wxASSERT(adviseSink.Ok()); // Get Dispatch interface @@ -951,7 +955,7 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk) 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);