ole32/composite: Cleanup IsRunning() implementation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2021-09-29 10:23:25 +03:00 committed by Alexandre Julliard
parent b8ba0e6fe0
commit 0806f9531f
2 changed files with 47 additions and 71 deletions

View File

@ -612,82 +612,49 @@ static HRESULT WINAPI CompositeMonikerImpl_Hash(IMoniker *iface, DWORD *hash)
return hr; return hr;
} }
/****************************************************************************** static HRESULT WINAPI CompositeMonikerImpl_IsRunning(IMoniker *iface, IBindCtx *pbc,
* CompositeMoniker_IsRunning IMoniker *toleft, IMoniker *newly_running)
******************************************************************************/
static HRESULT WINAPI
CompositeMonikerImpl_IsRunning(IMoniker* iface, IBindCtx* pbc,
IMoniker* pmkToLeft, IMoniker* pmkNewlyRunning)
{ {
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface);
IMoniker *c, *left, *rightmost;
IRunningObjectTable *rot; IRunningObjectTable *rot;
HRESULT res; HRESULT hr;
IMoniker *tempMk,*antiMk,*rightMostMk;
IEnumMoniker *enumMoniker;
TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning); TRACE("%p, %p, %p, %p.\n", iface, pbc, toleft, newly_running);
/* If pmkToLeft is non-NULL, this method composes pmkToLeft with this moniker and calls IsRunning on the result.*/ if (!pbc)
if (pmkToLeft!=NULL){
CreateGenericComposite(pmkToLeft,iface,&tempMk);
res = IMoniker_IsRunning(tempMk,pbc,NULL,pmkNewlyRunning);
IMoniker_Release(tempMk);
return res;
}
else
/* If pmkToLeft is NULL, this method returns S_OK if pmkNewlyRunning is non-NULL and is equal */
/* to this moniker */
if (pmkNewlyRunning!=NULL)
if (IMoniker_IsEqual(iface,pmkNewlyRunning)==S_OK)
return S_OK;
else
return S_FALSE;
else{
if (pbc==NULL)
return E_INVALIDARG; return E_INVALIDARG;
/* If pmkToLeft and pmkNewlyRunning are both NULL, this method checks the ROT to see whether */ if (toleft)
/* the moniker is running. If so, the method returns S_OK; otherwise, it recursively calls */ {
/* IMoniker::IsRunning on the rightmost component of the composite, passing the remainder of */ if (SUCCEEDED(hr = CreateGenericComposite(toleft, iface, &c)))
/* the composite as the pmkToLeft parameter for that call. */ {
hr = IMoniker_IsRunning(c, pbc, NULL, newly_running);
IMoniker_Release(c);
}
res=IBindCtx_GetRunningObjectTable(pbc,&rot); return hr;
}
if (FAILED(res)) if (newly_running)
return res; return IMoniker_IsEqual(iface, newly_running);
res = IRunningObjectTable_IsRunning(rot,iface); if (FAILED(hr = IBindCtx_GetRunningObjectTable(pbc, &rot)))
return hr;
hr = IRunningObjectTable_IsRunning(rot, iface);
IRunningObjectTable_Release(rot); IRunningObjectTable_Release(rot);
if (hr == S_OK) return S_OK;
if(res==S_OK) if (FAILED(hr = composite_get_rightmost(moniker, &left, &rightmost)))
return S_OK; return hr;
else{ hr = IMoniker_IsRunning(rightmost, pbc, left, NULL);
IMoniker_Enum(iface,FALSE,&enumMoniker); IMoniker_Release(left);
IEnumMoniker_Next(enumMoniker,1,&rightMostMk,NULL); IMoniker_Release(rightmost);
IEnumMoniker_Release(enumMoniker);
res=CreateAntiMoniker(&antiMk); return hr;
res=IMoniker_ComposeWith(iface,antiMk,0,&tempMk);
IMoniker_Release(antiMk);
res=IMoniker_IsRunning(rightMostMk,pbc,tempMk,pmkNewlyRunning);
IMoniker_Release(tempMk);
IMoniker_Release(rightMostMk);
return res;
}
}
} }
static HRESULT WINAPI CompositeMonikerImpl_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc, static HRESULT WINAPI CompositeMonikerImpl_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc,

View File

@ -3273,6 +3273,15 @@ todo_wine
hr = IMoniker_IsRunning(moniker, bindctx, NULL, NULL); hr = IMoniker_IsRunning(moniker, bindctx, NULL, NULL);
ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr); ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
hr = IMoniker_IsRunning(moniker, bindctx, NULL, moniker);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_IsRunning(moniker, bindctx, moniker1, moniker);
ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
hr = IMoniker_IsRunning(moniker, NULL, moniker1, moniker);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_GetTimeOfLastChange(moniker, bindctx, NULL, &filetime); hr = IMoniker_GetTimeOfLastChange(moniker, bindctx, NULL, &filetime);
ok(hr == MK_E_NOTBINDABLE, "IMoniker_GetTimeOfLastChange should return MK_E_NOTBINDABLE, not 0x%08x\n", hr); ok(hr == MK_E_NOTBINDABLE, "IMoniker_GetTimeOfLastChange should return MK_E_NOTBINDABLE, not 0x%08x\n", hr);