ieframe: Restore closed IOleClientSite in DoVerb.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2016-04-11 18:46:09 +02:00 committed by Alexandre Julliard
parent b555f41020
commit 17379dcd08
3 changed files with 46 additions and 7 deletions

View File

@ -190,6 +190,7 @@ struct WebBrowser {
INT version;
IOleClientSite *client;
IOleClientSite *client_closed;
IOleContainer *container;
IOleInPlaceSiteEx *inplace;

View File

@ -292,6 +292,11 @@ static void release_client_site(WebBrowser *This)
This->client = NULL;
}
if(This->client_closed) {
IOleClientSite_Release(This->client_closed);
This->client_closed = NULL;
}
if(This->shell_embedding_hwnd) {
DestroyWindow(This->shell_embedding_hwnd);
This->shell_embedding_hwnd = NULL;
@ -460,6 +465,11 @@ static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, LPOLECLIENTSITE
TRACE("(%p)->(%p)\n", This, pClientSite);
if(This->client_closed) {
IOleClientSite_Release(This->client_closed);
This->client_closed = NULL;
}
if(This->client == pClientSite)
return S_OK;
@ -549,6 +559,8 @@ static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szCont
static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
{
WebBrowser *This = impl_from_IOleObject(iface);
IOleClientSite *client;
HRESULT hres;
TRACE("(%p)->(%d)\n", This, dwSaveOption);
@ -569,7 +581,13 @@ static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
if(This->inplace)
IOleInPlaceSiteEx_OnInPlaceDeactivate(This->inplace);
return IOleObject_SetClientSite(iface, NULL);
/* store old client site - we need to restore it in DoVerb */
client = This->client;
if(This->client)
IOleClientSite_AddRef(This->client);
hres = IOleObject_SetClientSite(iface, NULL);
This->client_closed = client;
return hres;
}
static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker* pmk)
@ -611,6 +629,14 @@ static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tag
TRACE("(%p)->(%d %p %p %d %p %s)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent,
wine_dbgstr_rect(lprcPosRect));
/* restore closed client site if we have one */
if(!This->client && This->client_closed) {
IOleClientSite *client = This->client_closed;
This->client_closed = NULL;
IOleObject_SetClientSite(iface, client);
IOleClientSite_Release(client);
}
switch (iVerb)
{
case OLEIVERB_SHOW:

View File

@ -51,7 +51,7 @@ DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
#define SET_EXPECT(func) \
expect_ ## func = TRUE
do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
#define CHECK_EXPECT2(func) \
do { \
@ -71,6 +71,12 @@ DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define CHECK_NOT_CALLED(func) \
do { \
ok(!called_ ## func, "unexpected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
#define CLEAR_CALLED(func) \
expect_ ## func = called_ ## func = FALSE
@ -3633,19 +3639,25 @@ static void test_Close(IWebBrowser2 *wb, BOOL do_download)
hres = IOleObject_DoVerb(oo, OLEIVERB_HIDE, NULL, (IOleClientSite*)0xdeadbeef,
0, (HWND)0xdeadbeef, NULL);
ok(hres == S_OK, "DoVerb failed: %08x\n", hres);
todo_wine CHECK_CALLED(GetContainer);
todo_wine CHECK_CALLED(Site_GetWindow);
todo_wine CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
todo_wine CHECK_CALLED(Invoke_AMBIENT_SILENT);
CHECK_CALLED(GetContainer);
CHECK_CALLED(Site_GetWindow);
CHECK_CALLED(Invoke_AMBIENT_OFFLINEIFNOTCONNECTED);
CHECK_CALLED(Invoke_AMBIENT_SILENT);
hres = IOleObject_GetClientSite(oo, &ocs);
ok(hres == S_OK, "hres = %x\n", hres);
todo_wine ok(ocs == &ClientSite, "ocs != &ClientSite\n");
ok(ocs == &ClientSite, "ocs != &ClientSite\n");
if(ocs)
IOleClientSite_Release(ocs);
SET_EXPECT(OnFocus_FALSE);
SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
SET_EXPECT(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
hres = IOleObject_Close(oo, OLECLOSE_NOSAVE);
ok(hres == S_OK, "OleObject_Close failed: %x\n", hres);
todo_wine CHECK_NOT_CALLED(OnFocus_FALSE);
todo_wine CHECK_NOT_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEBACK_FALSE);
todo_wine CHECK_NOT_CALLED(Invoke_COMMANDSTATECHANGE_NAVIGATEFORWARD_FALSE);
test_close = FALSE;
IOleObject_Release(oo);