Commit 60451f98 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ole32: Create interface stub only if it's not already created.

parent f87491d5
......@@ -122,9 +122,7 @@ HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnkno
struct stub_manager *manager;
struct ifstub *ifstub;
BOOL tablemarshal;
IRpcStubBuffer *stub = NULL;
HRESULT hr;
IUnknown *iobject = NULL; /* object of type riid */
hr = apartment_getoxid(apt, &stdobjref->oxid);
if (hr != S_OK)
......@@ -134,39 +132,6 @@ HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnkno
if (hr != S_OK)
return hr;
hr = IUnknown_QueryInterface(object, riid, (void **)&iobject);
if (hr != S_OK)
{
ERR("object doesn't expose interface %s, failing with error 0x%08x\n",
debugstr_guid(riid), hr);
return E_NOINTERFACE;
}
/* IUnknown doesn't require a stub buffer, because it never goes out on
* the wire */
if (!IsEqualIID(riid, &IID_IUnknown))
{
IPSFactoryBuffer *psfb;
hr = get_facbuf_for_iid(riid, &psfb);
if (hr != S_OK)
{
ERR("couldn't get IPSFactory buffer for interface %s\n", debugstr_guid(riid));
IUnknown_Release(iobject);
return hr;
}
hr = IPSFactoryBuffer_CreateStub(psfb, riid, iobject, &stub);
IPSFactoryBuffer_Release(psfb);
if (hr != S_OK)
{
ERR("Failed to create an IRpcStubBuffer from IPSFactory for %s with error 0x%08x\n",
debugstr_guid(riid), hr);
IUnknown_Release(iobject);
return hr;
}
}
stdobjref->flags = SORF_NULL;
if (mshlflags & MSHLFLAGS_TABLEWEAK)
stdobjref->flags |= SORFP_TABLEWEAK;
......@@ -181,11 +146,7 @@ HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnkno
manager = new_stub_manager(apt, object);
if (!manager)
{
if (stub) IRpcStubBuffer_Release(stub);
IUnknown_Release(iobject);
return E_OUTOFMEMORY;
}
}
stdobjref->oid = manager->oid;
......@@ -193,19 +154,50 @@ HRESULT marshal_object(APARTMENT *apt, STDOBJREF *stdobjref, REFIID riid, IUnkno
/* make sure ifstub that we are creating is unique */
ifstub = stub_manager_find_ifstub(manager, riid, mshlflags);
if (!ifstub)
ifstub = stub_manager_new_ifstub(manager, stub, iobject, riid, dest_context, dest_context_data, mshlflags);
if (!ifstub) {
IRpcStubBuffer *stub = NULL;
IUnknown *iobject = NULL; /* object of type riid */
if (stub) IRpcStubBuffer_Release(stub);
IUnknown_Release(iobject);
hr = IUnknown_QueryInterface(object, riid, (void **)&iobject);
if (hr != S_OK)
ERR("object doesn't expose interface %s, failing with error 0x%08x\n",
debugstr_guid(riid), hr);
if (!ifstub)
{
stub_manager_int_release(manager);
/* destroy the stub manager if it has no ifstubs by releasing
* zero external references */
stub_manager_ext_release(manager, 0, FALSE, TRUE);
return E_OUTOFMEMORY;
/* IUnknown doesn't require a stub buffer, because it never goes out on
* the wire */
if (hr == S_OK && !IsEqualIID(riid, &IID_IUnknown))
{
IPSFactoryBuffer *psfb;
hr = get_facbuf_for_iid(riid, &psfb);
if (hr == S_OK) {
hr = IPSFactoryBuffer_CreateStub(psfb, riid, manager->object, &stub);
IPSFactoryBuffer_Release(psfb);
if (hr != S_OK)
ERR("Failed to create an IRpcStubBuffer from IPSFactory for %s with error 0x%08x\n",
debugstr_guid(riid), hr);
}else {
ERR("couldn't get IPSFactory buffer for interface %s\n", debugstr_guid(riid));
hr = E_NOINTERFACE;
}
}
if (hr == S_OK) {
ifstub = stub_manager_new_ifstub(manager, stub, iobject, riid, dest_context, dest_context_data, mshlflags);
if (!ifstub)
hr = E_OUTOFMEMORY;
}
if (stub) IRpcStubBuffer_Release(stub);
if (iobject) IUnknown_Release(iobject);
if (hr != S_OK) {
stub_manager_int_release(manager);
/* destroy the stub manager if it has no ifstubs by releasing
* zero external references */
stub_manager_ext_release(manager, 0, FALSE, TRUE);
return hr;
}
}
if (!tablemarshal)
......
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