Implement a Stop function and use this to properly implement

IOleObject_Close, IAdviseSink_OnClose and the destructor.
This commit is contained in:
Robert Shearman 2005-10-26 10:12:49 +00:00 committed by Alexandre Julliard
parent 5c2a708d51
commit 22c97cd98a
1 changed files with 42 additions and 8 deletions

View File

@ -394,6 +394,25 @@ static HRESULT WINAPI DefaultHandler_SetHostNames(
return S_OK; return S_OK;
} }
/* undos the work done by DefaultHandler_Run */
static void WINAPI DefaultHandler_Stop(DefaultHandler *This)
{
if (!This->pOleDelegate)
return;
IOleObject_Unadvise(This->pOleDelegate, This->dwAdvConn);
/* FIXME: call IOleCache_OnStop */
if (This->pPSDelegate)
{
IPersistStorage_Release(This->pPSDelegate);
This->pPSDelegate = NULL;
}
IOleObject_Release(This->pOleDelegate);
This->pOleDelegate = NULL;
}
/************************************************************************ /************************************************************************
* DefaultHandler_Close (IOleObject) * DefaultHandler_Close (IOleObject)
* *
@ -406,8 +425,19 @@ static HRESULT WINAPI DefaultHandler_Close(
IOleObject* iface, IOleObject* iface,
DWORD dwSaveOption) DWORD dwSaveOption)
{ {
FIXME("()\n"); DefaultHandler *This = impl_from_IOleObject(iface);
return S_OK; HRESULT hr;
TRACE("(%ld)\n", dwSaveOption);
if (!This->pOleDelegate)
return S_OK;
hr = IOleObject_Close(This->pOleDelegate, dwSaveOption);
DefaultHandler_Stop(This);
return hr;
} }
/************************************************************************ /************************************************************************
@ -1204,7 +1234,7 @@ static HRESULT WINAPI DefaultHandler_Run(
/* FIXME: do more stuff here: /* FIXME: do more stuff here:
* - IOleObject_GetMiscStatus * - IOleObject_GetMiscStatus
* - IOleObject_GetMoniker * - IOleObject_GetMoniker
* - advise data cache that we've connected somehow? * - IOleCache_OnRun
*/ */
/* FIXME: if we failed, Close the object */ /* FIXME: if we failed, Close the object */
@ -1321,7 +1351,13 @@ static void WINAPI DefaultHandler_IAdviseSink_OnSave(
static void WINAPI DefaultHandler_IAdviseSink_OnClose( static void WINAPI DefaultHandler_IAdviseSink_OnClose(
IAdviseSink *iface) IAdviseSink *iface)
{ {
FIXME(": stub\n"); DefaultHandler *This = impl_from_IAdviseSink(iface);
TRACE("()\n");
IOleAdviseHolder_SendOnClose(This->oleAdviseHolder);
DefaultHandler_Stop(This);
} }
/* /*
@ -1472,10 +1508,8 @@ static DefaultHandler* DefaultHandler_Construct(
static void DefaultHandler_Destroy( static void DefaultHandler_Destroy(
DefaultHandler* This) DefaultHandler* This)
{ {
if (This->pOleDelegate) /* release delegates */
IOleObject_Release(This->pOleDelegate); DefaultHandler_Stop(This);
if (This->pPSDelegate)
IPersistStorage_Release(This->pPSDelegate);
/* Free the strings idenfitying the object */ /* Free the strings idenfitying the object */
HeapFree( GetProcessHeap(), 0, This->containerApp ); HeapFree( GetProcessHeap(), 0, This->containerApp );