Commit 70f35c65 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Fix equality check in CommonPrefixWith() for pointer moniker.

parent 5a93d972
......@@ -48,9 +48,10 @@ typedef struct PointerMonikerImpl{
static inline PointerMonikerImpl *impl_from_IMoniker(IMoniker *iface)
{
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
}
static PointerMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface);
static HRESULT WINAPI
PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
{
......@@ -58,7 +59,6 @@ PointerMonikerImpl_QueryInterface(IMoniker* iface,REFIID riid,void** ppvObject)
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
/* Perform a sanity check on the parameters.*/
if ( (This==0) || (ppvObject==0) )
return E_INVALIDARG;
......@@ -337,26 +337,20 @@ PointerMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoni
/******************************************************************************
* PointerMoniker_IsEqual
******************************************************************************/
static HRESULT WINAPI
PointerMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
static HRESULT WINAPI PointerMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
{
PointerMonikerImpl *This = impl_from_IMoniker(iface);
DWORD mkSys;
PointerMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
if (pmkOtherMoniker==NULL)
return S_FALSE;
TRACE("%p, %p.\n", iface, other);
IMoniker_IsSystemMoniker(pmkOtherMoniker,&mkSys);
if (!other)
return E_INVALIDARG;
if (mkSys==MKSYS_POINTERMONIKER)
{
PointerMonikerImpl *pOtherMoniker = impl_from_IMoniker(pmkOtherMoniker);
return This->pObject == pOtherMoniker->pObject ? S_OK : S_FALSE;
}
else
other_moniker = unsafe_impl_from_IMoniker(other);
if (!other_moniker)
return S_FALSE;
return moniker->pObject == other_moniker->pObject ? S_OK : S_FALSE;
}
/******************************************************************************
......@@ -412,18 +406,20 @@ PointerMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
/******************************************************************************
* PointerMoniker_CommonPrefixWith
******************************************************************************/
static HRESULT WINAPI
PointerMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
static HRESULT WINAPI PointerMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *other, IMoniker **prefix)
{
TRACE("(%p, %p)\n", pmkOther, ppmkPrefix);
TRACE("%p, %p, %p.\n", iface, other, prefix);
if (!prefix || !other)
return E_INVALIDARG;
*ppmkPrefix = NULL;
*prefix = NULL;
if (PointerMonikerImpl_IsEqual(iface, pmkOther))
if (PointerMonikerImpl_IsEqual(iface, other) == S_OK)
{
IMoniker_AddRef(iface);
*ppmkPrefix=iface;
*prefix = iface;
return MK_S_US;
}
......@@ -539,6 +535,13 @@ static const IMonikerVtbl VT_PointerMonikerImpl =
PointerMonikerImpl_IsSystemMoniker
};
static PointerMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface)
{
if (iface->lpVtbl != &VT_PointerMonikerImpl)
return NULL;
return CONTAINING_RECORD(iface, PointerMonikerImpl, IMoniker_iface);
}
/******************************************************************************
* PointerMoniker_Construct (local function)
*******************************************************************************/
......
......@@ -2625,7 +2625,7 @@ todo_wine
static void test_pointer_moniker(void)
{
IMoniker *moniker, *inverse;
IMoniker *moniker, *moniker2, *prefix, *inverse;
IEnumMoniker *enummoniker;
HRESULT hr;
DWORD moniker_type;
......@@ -2748,6 +2748,45 @@ todo_wine
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker);
/* CommonPrefixWith() */
hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker);
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker2);
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, moniker2);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, NULL, &prefix);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &prefix);
ok(hr == MK_S_US, "Unexpected hr %#x.\n", hr);
ok(prefix == moniker, "Unexpected pointer.\n");
IMoniker_Release(prefix);
IMoniker_Release(moniker2);
hr = CreatePointerMoniker((IUnknown *)moniker, &moniker2);
ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr);
hr = IMoniker_IsEqual(moniker, moniker2);
ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
hr = IMoniker_CommonPrefixWith(moniker, moniker2, &prefix);
ok(hr == MK_E_NOPREFIX, "Unexpected hr %#x.\n", hr);
IMoniker_Release(moniker2);
IMoniker_Release(moniker);
}
static void test_bind_context(void)
......
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