shdocvw: Deactivate document in SetClientSite if ClientSite is NULL.

Fix ref counting.
oldstable
Jacek Caban 2006-01-18 13:22:52 +01:00 committed by Alexandre Julliard
parent 23ead2b174
commit 47f796c629
5 changed files with 67 additions and 4 deletions

View File

@ -204,6 +204,7 @@ static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
TRACE("(%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect,
lprcClipRect, lpFrameInfo);
IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
*ppFrame = INPLACEFRAME(This);
*ppDoc = NULL;

View File

@ -154,6 +154,58 @@ void create_doc_view_hwnd(WebBrowser *This)
NULL, shdocvw_hinstance, This);
}
void deactivate_document(WebBrowser *This)
{
IOleInPlaceObjectWindowless *winobj;
IOleObject *oleobj = NULL;
IHlinkTarget *hlink = NULL;
HRESULT hres;
if(This->view)
IOleDocumentView_UIActivate(This->view, FALSE);
hres = IUnknown_QueryInterface(This->client, &IID_IOleInPlaceObjectWindowless,
(void**)&winobj);
if(SUCCEEDED(hres)) {
IOleInPlaceObjectWindowless_InPlaceDeactivate(winobj);
IOleInPlaceObjectWindowless_Release(winobj);
}
if(This->view) {
IOleDocumentView_Show(This->view, FALSE);
IOleDocumentView_CloseView(This->view, 0);
IOleDocumentView_SetInPlaceSite(This->view, NULL);
IOleDocumentView_Release(This->view);
This->view = NULL;
}
hres = IUnknown_QueryInterface(This->document, &IID_IOleObject, (void**)&oleobj);
if(SUCCEEDED(hres))
IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
hres = IUnknown_QueryInterface(This->document, &IID_IHlinkTarget, (void**)&hlink);
if(SUCCEEDED(hres)) {
IHlinkTarget_SetBrowseContext(hlink, NULL);
IHlinkTarget_Release(hlink);
}
if(oleobj) {
IOleClientSite *client_site = NULL;
IOleObject_GetClientSite(oleobj, &client_site);
if(client_site) {
if(client_site == CLIENTSITE(This))
IOleObject_SetClientSite(oleobj, NULL);
IOleClientSite_Release(client_site);
}
IOleObject_Release(oleobj);
}
IUnknown_Release(This->document);
This->document = NULL;
}
#define DOCHOSTUI_THIS(iface) DEFINE_THIS(WebBrowser, DocHostUIHandler, iface)
static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,

View File

@ -177,6 +177,7 @@ static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoi
TRACE("(%p)->(%p)\n", This, ppCPC);
*ppCPC = CONPTCONT(This->webbrowser);
IConnectionPointContainer_AddRef(CONPTCONT(This->webbrowser));
return S_OK;
}

View File

@ -130,18 +130,26 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
if(This->client == pClientSite)
return S_OK;
if(This->doc_view_hwnd)
if(This->doc_view_hwnd) {
DestroyWindow(This->doc_view_hwnd);
if(This->shell_embedding_hwnd)
This->doc_view_hwnd = NULL;
}
if(This->shell_embedding_hwnd) {
DestroyWindow(This->shell_embedding_hwnd);
This->shell_embedding_hwnd = NULL;
}
if(This->client)
IOleClientSite_Release(This->client);
This->client = pClientSite;
if(!pClientSite)
if(!pClientSite) {
if(This->document)
deactivate_document(This);
This->client = NULL;
return S_OK;
}
This->client = pClientSite;
IOleClientSite_AddRef(pClientSite);
create_shell_embedding_hwnd(This);

View File

@ -158,6 +158,7 @@ void WebBrowser_ClientSite_Destroy(WebBrowser*);
HRESULT WebBrowser_Create(IUnknown*,REFIID,void**);
void create_doc_view_hwnd(WebBrowser *This);
void deactivate_document(WebBrowser*);
void call_sink(ConnectionPoint*,DISPID,DISPPARAMS*);
#define WB_WM_NAVIGATE2 (WM_USER+100)