From: Vibhav Pant vibhavp@gmail.com
--- dlls/combase/roapi.c | 12 +++++++++++- dlls/combase/tests/roapi.c | 11 ----------- 2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/dlls/combase/roapi.c b/dlls/combase/roapi.c index df3a3c5c176..7c15dc5d148 100644 --- a/dlls/combase/roapi.c +++ b/dlls/combase/roapi.c @@ -245,6 +245,7 @@ struct agile_reference IStream *marshal_stream; CRITICAL_SECTION cs; IUnknown *obj; + BOOLEAN is_agile; LONG ref; };
@@ -331,6 +332,9 @@ static HRESULT WINAPI agile_ref_Resolve(IAgileReference *iface, REFIID riid, voi
TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), obj);
+ if (impl->is_agile) + return IUnknown_QueryInterface(impl->obj, riid, obj); + EnterCriticalSection(&impl->cs); if (impl->option == AGILEREFERENCE_DELAYEDMARSHAL && impl->marshal_stream == NULL) { @@ -400,7 +404,13 @@ HRESULT WINAPI RoGetAgileReference(enum AgileReferenceOptions option, REFIID rii impl->option = option; impl->ref = 1;
- if (option == AGILEREFERENCE_DEFAULT) + hr = IUnknown_QueryInterface(obj, &IID_IAgileObject, (void **)&unknown); + if (SUCCEEDED(hr)) + { + impl->obj = obj; + impl->is_agile = TRUE; + } + else if (option == AGILEREFERENCE_DEFAULT) { if (FAILED(hr = marshal_object_in_agile_reference(impl, riid, obj))) { diff --git a/dlls/combase/tests/roapi.c b/dlls/combase/tests/roapi.c index a3337ed9b08..02284ab6cfc 100644 --- a/dlls/combase/tests/roapi.c +++ b/dlls/combase/tests/roapi.c @@ -450,9 +450,7 @@ static DWORD CALLBACK test_RoGetAgileReference_thread_proc(void *arg) ok(!!unknown, "Expected pointer not NULL.\n"); if (param->obj_is_agile) { - todo_wine_if(param->from_type == RO_INIT_SINGLETHREADED || param->to_type == RO_INIT_SINGLETHREADED) ok(unknown == param->unk_obj, "Expected the same object.\n"); - todo_wine_if(param->from_type == RO_INIT_MULTITHREADED && param->to_type == RO_INIT_MULTITHREADED) EXPECT_REF(param->unk_obj, 4); } else if (param->from_type == RO_INIT_MULTITHREADED && param->to_type == RO_INIT_MULTITHREADED) @@ -577,7 +575,6 @@ static void test_RoGetAgileReference(void) hr = RoGetAgileReference(option, &IID_IUnknown, &unk_agile_obj.IUnknown_iface, &agile_reference); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(!!agile_reference, "Got unexpected agile_reference.\n"); - todo_wine_if(option == AGILEREFERENCE_DEFAULT) EXPECT_REF(&unk_agile_obj, 2);
unknown = NULL; @@ -585,7 +582,6 @@ static void test_RoGetAgileReference(void) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(!!unknown, "Expected pointer not NULL.\n"); ok(unknown == &unk_agile_obj.IUnknown_iface, "Expected the same object.\n"); - todo_wine EXPECT_REF(&unk_agile_obj, 3);
for (to_type = RO_INIT_SINGLETHREADED; to_type <= RO_INIT_MULTITHREADED; to_type++) @@ -612,24 +608,17 @@ static void test_RoGetAgileReference(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); agile_reference = NULL; hr = RoGetAgileReference(option, &IID_IApiInformationStatics, (IUnknown *)statics, &agile_reference); - todo_wine_if(option == AGILEREFERENCE_DEFAULT) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine_if(option == AGILEREFERENCE_DEFAULT) ok(!!agile_reference, "Got unexpected agile_reference.\n"); - todo_wine_if(option == AGILEREFERENCE_DEFAULT) EXPECT_REF(statics, 3);
if (SUCCEEDED(hr)) { statics2 = NULL; hr = IAgileReference_Resolve(agile_reference, &IID_IApiInformationStatics, (void **)&statics2); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(!!statics2, "Expected pointer not NULL.\n"); - todo_wine ok(statics2 == statics, "Expected the same object.\n"); - todo_wine EXPECT_REF(statics, 4);
if (SUCCEEDED(hr))