ole32: Fix IsEqual() for item moniker.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Nikolay Sivov 2020-01-23 02:03:06 +03:00 committed by Alexandre Julliard
parent 0b0b0795c7
commit 5330878db7
2 changed files with 21 additions and 25 deletions

View File

@ -52,6 +52,8 @@ static inline ItemMonikerImpl *impl_from_IMoniker(IMoniker *iface)
return CONTAINING_RECORD(iface, ItemMonikerImpl, IMoniker_iface);
}
static ItemMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface);
static inline ItemMonikerImpl *impl_from_IROTData(IROTData *iface)
{
return CONTAINING_RECORD(iface, ItemMonikerImpl, IROTData_iface);
@ -601,34 +603,20 @@ static HRESULT WINAPI ItemMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumM
/******************************************************************************
* ItemMoniker_IsEqual
******************************************************************************/
static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
static HRESULT WINAPI ItemMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
{
ItemMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
CLSID clsid;
LPOLESTR dispName1,dispName2;
IBindCtx* bind;
HRESULT res = S_FALSE;
TRACE("%p, %p.\n", iface, other);
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
if (!other)
return E_INVALIDARG;
if (!pmkOtherMoniker) return S_FALSE;
other_moniker = unsafe_impl_from_IMoniker(other);
if (!other_moniker)
return S_FALSE;
/* check if both are ItemMoniker */
if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE;
if(!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) return S_FALSE;
/* check if both displaynames are the same */
if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) {
if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) {
if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) {
if(wcscmp(dispName1,dispName2)==0) res = S_OK;
CoTaskMemFree(dispName2);
}
CoTaskMemFree(dispName1);
}
}
return res;
return !wcsicmp(moniker->itemName, other_moniker->itemName) ? S_OK : S_FALSE;
}
/******************************************************************************
@ -1002,6 +990,13 @@ static const IMonikerVtbl VT_ItemMonikerImpl =
ItemMonikerImpl_IsSystemMoniker
};
static ItemMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface)
{
if (iface->lpVtbl != &VT_ItemMonikerImpl)
return NULL;
return CONTAINING_RECORD(iface, ItemMonikerImpl, IMoniker_iface);
}
/********************************************************************************/
/* Virtual function table for the IROTData class. */
static const IROTDataVtbl VT_ROTDataImpl =

View File

@ -2193,6 +2193,9 @@ todo_wine
todo_wine
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker);
/* IsEqual */
@ -2205,11 +2208,9 @@ todo_wine
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, moniker2);
todo_wine_if(i == 4 || i == 5)
ok(hr == isequal_tests[i].hr, "%d: unexpected result %#x.\n", i, hr);
hr = IMoniker_IsEqual(moniker2, moniker);
todo_wine_if(i == 4 || i == 5)
ok(hr == isequal_tests[i].hr, "%d: unexpected result %#x.\n", i, hr);
IMoniker_Release(moniker);