From 7c6dcab73f9b34ae6dba662a2eb374298098a4f4 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 28 Mar 2016 13:33:56 +0300 Subject: [PATCH] dwrite: Use regular QI way to return interface client asked for. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/main.c | 22 +++++++--------------- dlls/dwrite/tests/font.c | 9 +++++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index e081e11b540..b82a4b07b69 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1313,21 +1313,14 @@ static void init_dwritefactory(struct dwritefactory *factory, DWRITE_FACTORY_TYP HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **ret) { struct dwritefactory *factory; + HRESULT hr; TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), ret); *ret = NULL; - if (!IsEqualIID(riid, &IID_IDWriteFactory) && - !IsEqualIID(riid, &IID_IDWriteFactory1) && - !IsEqualIID(riid, &IID_IDWriteFactory2)) - return E_FAIL; - - if (type == DWRITE_FACTORY_TYPE_SHARED && shared_factory) { - *ret = (IUnknown*)shared_factory; - IDWriteFactory2_AddRef(shared_factory); - return S_OK; - } + if (type == DWRITE_FACTORY_TYPE_SHARED && shared_factory) + return IDWriteFactory2_QueryInterface(shared_factory, riid, (void**)ret); factory = heap_alloc(sizeof(struct dwritefactory)); if (!factory) return E_OUTOFMEMORY; @@ -1337,11 +1330,10 @@ HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnkno if (type == DWRITE_FACTORY_TYPE_SHARED) if (InterlockedCompareExchangePointer((void**)&shared_factory, &factory->IDWriteFactory2_iface, NULL)) { release_shared_factory(&factory->IDWriteFactory2_iface); - *ret = (IUnknown*)shared_factory; - IDWriteFactory2_AddRef(shared_factory); - return S_OK; + return IDWriteFactory2_QueryInterface(shared_factory, riid, (void**)ret); } - *ret = (IUnknown*)&factory->IDWriteFactory2_iface; - return S_OK; + hr = IDWriteFactory2_QueryInterface(&factory->IDWriteFactory2_iface, riid, (void**)ret); + IDWriteFactory2_Release(&factory->IDWriteFactory2_iface); + return hr; } diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 7c19f000493..766df393309 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -2312,6 +2312,11 @@ static void test_shared_isolated(void) hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2); ok(hr == S_OK, "got 0x%08x\n", hr); ok(shared == shared2, "got %p, and %p\n", shared, shared2); + IDWriteFactory_Release(shared2); + + hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IUnknown, (IUnknown**)&shared2); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(shared == shared2, "got %p, and %p\n", shared, shared2); IDWriteFactory_Release(shared); IDWriteFactory_Release(shared2); @@ -2330,6 +2335,10 @@ static void test_shared_isolated(void) ok(isolated != isolated2, "got %p, and %p\n", isolated, isolated2); IDWriteFactory_Release(isolated2); + hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, &IID_IUnknown, (IUnknown**)&isolated2); + ok(hr == S_OK, "got 0x%08x\n", hr); + IDWriteFactory_Release(isolated2); + hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED+1, &IID_IDWriteFactory, (IUnknown**)&isolated2); ok(hr == S_OK, "got 0x%08x\n", hr); ok(shared != isolated2, "got %p, and %p\n", shared, isolated2);