fix memory leak of FrameSite (see #3935)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-13 23:04:03 +00:00
parent 0641c71271
commit 9b53796d59
2 changed files with 9 additions and 4 deletions

View File

@@ -155,6 +155,7 @@ protected:
friend class FrameSite; friend class FrameSite;
friend class wxActiveXEvents; friend class wxActiveXEvents;
FrameSite *m_frameSite;
wxAutoIDispatch m_Dispatch; wxAutoIDispatch m_Dispatch;
wxAutoIOleClientSite m_clientSite; wxAutoIOleClientSite m_clientSite;
wxAutoIUnknown m_ActiveX; wxAutoIUnknown m_ActiveX;

View File

@@ -829,6 +829,10 @@ wxActiveXContainer::~wxActiveXContainer()
m_oleObject->Close(OLECLOSE_NOSAVE); m_oleObject->Close(OLECLOSE_NOSAVE);
m_oleObject->SetClientSite(NULL); 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); CHECK_HR(hret);
// FrameSite // FrameSite
FrameSite *frame = new FrameSite(m_realparent, this); m_frameSite = new FrameSite(m_realparent, this);
// oleClientSite // oleClientSite
hret = m_clientSite.QueryInterface( hret = m_clientSite.QueryInterface(
IID_IOleClientSite, (IDispatch *) frame); IID_IOleClientSite, (IDispatch *) m_frameSite);
CHECK_HR(hret); CHECK_HR(hret);
// adviseSink // adviseSink
wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) frame); wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite);
wxASSERT(adviseSink.Ok()); wxASSERT(adviseSink.Ok());
// Get Dispatch interface // Get Dispatch interface
@@ -951,7 +955,7 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
CHECK_HR(hret); CHECK_HR(hret);
IDispatch* disp; IDispatch* disp;
frame->QueryInterface(IID_IDispatch, (void**)&disp); m_frameSite->QueryInterface(IID_IDispatch, (void**)&disp);
hret = cp->Advise(new wxActiveXEvents(this, ta->guid), hret = cp->Advise(new wxActiveXEvents(this, ta->guid),
&adviseCookie); &adviseCookie);
CHECK_HR(hret); CHECK_HR(hret);