ole32: Defer releasing the delegate interfaces until after we return from an OnClose notification.
This commit is contained in:
parent
8730bf66c9
commit
8355eeaa21
|
@ -71,6 +71,12 @@ enum storage_state
|
|||
storage_state_loaded
|
||||
};
|
||||
|
||||
enum object_state
|
||||
{
|
||||
object_state_not_running,
|
||||
object_state_running
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* DefaultHandler
|
||||
*
|
||||
|
@ -123,6 +129,7 @@ struct DefaultHandler
|
|||
IPersistStorage *pPSDelegate;
|
||||
/* IDataObject delegate */
|
||||
IDataObject *pDataDelegate;
|
||||
enum object_state object_state;
|
||||
|
||||
/* connection cookie for the advise on the delegate OLE object */
|
||||
DWORD dwAdvConn;
|
||||
|
@ -452,7 +459,7 @@ static void DefaultHandler_Stop(DefaultHandler *This)
|
|||
if (This->dataAdviseHolder)
|
||||
DataAdviseHolder_OnDisconnect(This->dataAdviseHolder);
|
||||
|
||||
release_delegates(This);
|
||||
This->object_state = object_state_not_running;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
@ -478,6 +485,7 @@ static HRESULT WINAPI DefaultHandler_Close(
|
|||
hr = IOleObject_Close(This->pOleDelegate, dwSaveOption);
|
||||
|
||||
DefaultHandler_Stop(This);
|
||||
release_delegates(This);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -1305,11 +1313,15 @@ static HRESULT WINAPI DefaultHandler_Run(
|
|||
if (object_is_running(This))
|
||||
return S_OK;
|
||||
|
||||
release_delegates(This);
|
||||
|
||||
hr = CoCreateInstance(&This->clsid, NULL, CLSCTX_LOCAL_SERVER,
|
||||
&IID_IOleObject, (void **)&This->pOleDelegate);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
This->object_state = object_state_running;
|
||||
|
||||
hr = IOleObject_Advise(This->pOleDelegate,
|
||||
(IAdviseSink *)&This->lpvtblIAdviseSink,
|
||||
&This->dwAdvConn);
|
||||
|
@ -1348,7 +1360,10 @@ static HRESULT WINAPI DefaultHandler_Run(
|
|||
hr = DataAdviseHolder_OnConnect(This->dataAdviseHolder, This->pDataDelegate);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
DefaultHandler_Stop(This);
|
||||
release_delegates(This);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -1365,7 +1380,7 @@ static BOOL WINAPI DefaultHandler_IsRunning(
|
|||
|
||||
TRACE("()\n");
|
||||
|
||||
if (This->pOleDelegate)
|
||||
if (This->object_state == object_state_running)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
|
@ -1943,6 +1958,7 @@ static DefaultHandler* DefaultHandler_Construct(
|
|||
This->pOleDelegate = NULL;
|
||||
This->pPSDelegate = NULL;
|
||||
This->pDataDelegate = NULL;
|
||||
This->object_state = object_state_not_running;
|
||||
|
||||
This->dwAdvConn = 0;
|
||||
This->storage = NULL;
|
||||
|
@ -1956,6 +1972,7 @@ static void DefaultHandler_Destroy(
|
|||
{
|
||||
/* release delegates */
|
||||
DefaultHandler_Stop(This);
|
||||
release_delegates(This);
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, This->containerApp );
|
||||
This->containerApp = NULL;
|
||||
|
|
Loading…
Reference in New Issue