Commit 37da1e67 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- AddRef type info stored in StdDispatch.

- Don't use outer unknown in StdDispatch.
parent 18149487
...@@ -160,6 +160,9 @@ HRESULT WINAPI DispGetParam( ...@@ -160,6 +160,9 @@ HRESULT WINAPI DispGetParam(
* RETURNS * RETURNS
* Success: S_OK. ppunkStdDisp contains the new object. * Success: S_OK. ppunkStdDisp contains the new object.
* Failure: An HRESULT error code. * Failure: An HRESULT error code.
*
* NOTES
* Outer unknown appears to be completely ignored.
*/ */
HRESULT WINAPI CreateStdDispatch( HRESULT WINAPI CreateStdDispatch(
IUnknown* punkOuter, IUnknown* punkOuter,
...@@ -235,7 +238,6 @@ HRESULT WINAPI CreateDispTypeInfo( ...@@ -235,7 +238,6 @@ HRESULT WINAPI CreateDispTypeInfo(
typedef struct typedef struct
{ {
ICOM_VFIELD(IDispatch); ICOM_VFIELD(IDispatch);
IUnknown * outerUnknown;
void * pvThis; void * pvThis;
ITypeInfo * pTypeInfo; ITypeInfo * pTypeInfo;
ULONG ref; ULONG ref;
...@@ -254,9 +256,6 @@ static HRESULT WINAPI StdDispatch_QueryInterface( ...@@ -254,9 +256,6 @@ static HRESULT WINAPI StdDispatch_QueryInterface(
ICOM_THIS(StdDispatch, iface); ICOM_THIS(StdDispatch, iface);
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppvObject); TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppvObject);
if (This->outerUnknown)
return IUnknown_QueryInterface(This->outerUnknown, riid, ppvObject);
if (IsEqualIID(riid, &IID_IDispatch) || if (IsEqualIID(riid, &IID_IDispatch) ||
IsEqualIID(riid, &IID_IUnknown)) IsEqualIID(riid, &IID_IUnknown))
{ {
...@@ -276,11 +275,8 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface) ...@@ -276,11 +275,8 @@ static ULONG WINAPI StdDispatch_AddRef(LPDISPATCH iface)
{ {
ICOM_THIS(StdDispatch, iface); ICOM_THIS(StdDispatch, iface);
TRACE("()\n"); TRACE("()\n");
This->ref++;
if (This->outerUnknown) return ++This->ref;
return IUnknown_AddRef(This->outerUnknown);
else
return This->ref;
} }
/****************************************************************************** /******************************************************************************
...@@ -294,15 +290,13 @@ static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface) ...@@ -294,15 +290,13 @@ static ULONG WINAPI StdDispatch_Release(LPDISPATCH iface)
ULONG ret; ULONG ret;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
This->ref--; ret = This->ref--;
if (This->outerUnknown) if (This->ref == 0)
ret = IUnknown_Release(This->outerUnknown); {
else ITypeInfo_Release(This->pTypeInfo);
ret = This->ref;
if (This->ref <= 0)
CoTaskMemFree(This); CoTaskMemFree(This);
}
return ret; return ret;
} }
...@@ -469,10 +463,13 @@ static IDispatch * WINAPI StdDispatch_Construct( ...@@ -469,10 +463,13 @@ static IDispatch * WINAPI StdDispatch_Construct(
return (IDispatch *)pStdDispatch; return (IDispatch *)pStdDispatch;
pStdDispatch->lpVtbl = &StdDispatch_VTable; pStdDispatch->lpVtbl = &StdDispatch_VTable;
pStdDispatch->outerUnknown = punkOuter;
pStdDispatch->pvThis = pvThis; pStdDispatch->pvThis = pvThis;
pStdDispatch->pTypeInfo = pTypeInfo; pStdDispatch->pTypeInfo = pTypeInfo;
pStdDispatch->ref = 1; pStdDispatch->ref = 1;
/* we keep a reference to the type info so prevent it from
* being destroyed until we are done with it */
ITypeInfo_AddRef(pTypeInfo);
return (IDispatch *)pStdDispatch; return (IDispatch *)pStdDispatch;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment