ole32/composite: Fix IsEqual() comparison logic.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ca7e757fb9
commit
068ddc5b1b
|
@ -558,56 +558,41 @@ static HRESULT WINAPI CompositeMonikerImpl_Enum(IMoniker *iface, BOOL forward, I
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
static HRESULT WINAPI CompositeMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
|
||||||
* CompositeMoniker_IsEqual
|
|
||||||
******************************************************************************/
|
|
||||||
static HRESULT WINAPI
|
|
||||||
CompositeMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
|
||||||
{
|
{
|
||||||
IEnumMoniker *enumMoniker1,*enumMoniker2;
|
CompositeMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
|
||||||
IMoniker *tempMk1,*tempMk2;
|
IMoniker **components, **other_components;
|
||||||
HRESULT res1,res2,res;
|
unsigned int i;
|
||||||
BOOL done;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
|
TRACE("%p, %p.\n", iface, other);
|
||||||
|
|
||||||
if (pmkOtherMoniker==NULL)
|
if (!other)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
if (!(other_moniker = unsafe_impl_from_IMoniker(other)))
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
/* This method returns S_OK if the components of both monikers are equal when compared in the */
|
if (moniker->comp_count != other_moniker->comp_count)
|
||||||
/* left-to-right order.*/
|
|
||||||
IMoniker_Enum(pmkOtherMoniker,TRUE,&enumMoniker1);
|
|
||||||
|
|
||||||
if (enumMoniker1==NULL)
|
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
IMoniker_Enum(iface,TRUE,&enumMoniker2);
|
if (FAILED(hr = composite_get_components_alloc(moniker, &components))) return hr;
|
||||||
|
if (FAILED(hr = composite_get_components_alloc(other_moniker, &other_components)))
|
||||||
|
{
|
||||||
|
heap_free(components);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
for (i = 0; i < moniker->comp_count; ++i)
|
||||||
|
{
|
||||||
|
if ((hr = IMoniker_IsEqual(components[i], other_components[i]) != S_OK))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
res1=IEnumMoniker_Next(enumMoniker1,1,&tempMk1,NULL);
|
heap_free(other_components);
|
||||||
res2=IEnumMoniker_Next(enumMoniker2,1,&tempMk2,NULL);
|
heap_free(components);
|
||||||
|
|
||||||
if((res1==S_OK)&&(res2==S_OK)){
|
return hr;
|
||||||
done = (res = IMoniker_IsEqual(tempMk1,tempMk2)) == S_FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = (res1==S_FALSE) && (res2==S_FALSE);
|
|
||||||
done = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res1==S_OK)
|
|
||||||
IMoniker_Release(tempMk1);
|
|
||||||
|
|
||||||
if (res2==S_OK)
|
|
||||||
IMoniker_Release(tempMk2);
|
|
||||||
} while (!done);
|
|
||||||
|
|
||||||
IEnumMoniker_Release(enumMoniker1);
|
|
||||||
IEnumMoniker_Release(enumMoniker2);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI CompositeMonikerImpl_Hash(IMoniker *iface, DWORD *hash)
|
static HRESULT WINAPI CompositeMonikerImpl_Hash(IMoniker *iface, DWORD *hash)
|
||||||
|
|
|
@ -3303,20 +3303,16 @@ todo_wine
|
||||||
|
|
||||||
/* With itself */
|
/* With itself */
|
||||||
hr = IMoniker_CommonPrefixWith(moniker, moniker, &moniker2);
|
hr = IMoniker_CommonPrefixWith(moniker, moniker, &moniker2);
|
||||||
todo_wine
|
|
||||||
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
|
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
|
||||||
hr = IMoniker_IsEqual(moniker, moniker2);
|
hr = IMoniker_IsEqual(moniker, moniker2);
|
||||||
todo_wine
|
|
||||||
ok(hr == S_OK && moniker2 != moniker, "Unexpected hr %#x.\n", hr);
|
ok(hr == S_OK && moniker2 != moniker, "Unexpected hr %#x.\n", hr);
|
||||||
IMoniker_Release(moniker2);
|
IMoniker_Release(moniker2);
|
||||||
|
|
||||||
/* Equal composites */
|
/* Equal composites */
|
||||||
hr = IMoniker_CommonPrefixWith(moniker, moniker1, &moniker2);
|
hr = IMoniker_CommonPrefixWith(moniker, moniker1, &moniker2);
|
||||||
todo_wine
|
|
||||||
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
|
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
|
||||||
ok(moniker2 != moniker && moniker2 != moniker1, "Unexpected object.\n");
|
ok(moniker2 != moniker && moniker2 != moniker1, "Unexpected object.\n");
|
||||||
hr = IMoniker_IsEqual(moniker, moniker2);
|
hr = IMoniker_IsEqual(moniker, moniker2);
|
||||||
todo_wine
|
|
||||||
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
IMoniker_Release(moniker2);
|
IMoniker_Release(moniker2);
|
||||||
|
|
||||||
|
@ -3349,6 +3345,20 @@ todo_wine
|
||||||
IMoniker_Release(moniker);
|
IMoniker_Release(moniker);
|
||||||
IMoniker_Release(moniker1);
|
IMoniker_Release(moniker1);
|
||||||
|
|
||||||
|
/* IsEqual() */
|
||||||
|
hr = create_moniker_from_desc("CI1I2", &moniker1);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
hr = create_moniker_from_desc("CI1I2", &moniker2);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
hr = IMoniker_IsEqual(moniker1, NULL);
|
||||||
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
||||||
|
hr = IMoniker_IsEqual(moniker1, moniker2);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
hr = IMoniker_IsEqual(moniker1, moniker1);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
IMoniker_Release(moniker2);
|
||||||
|
IMoniker_Release(moniker1);
|
||||||
|
|
||||||
IBindCtx_Release(bindctx);
|
IBindCtx_Release(bindctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue