Commit 7c6dcab7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use regular QI way to return interface client asked for.

parent 19777292
...@@ -1313,21 +1313,14 @@ static void init_dwritefactory(struct dwritefactory *factory, DWRITE_FACTORY_TYP ...@@ -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) HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **ret)
{ {
struct dwritefactory *factory; struct dwritefactory *factory;
HRESULT hr;
TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), ret); TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), ret);
*ret = NULL; *ret = NULL;
if (!IsEqualIID(riid, &IID_IDWriteFactory) && if (type == DWRITE_FACTORY_TYPE_SHARED && shared_factory)
!IsEqualIID(riid, &IID_IDWriteFactory1) && return IDWriteFactory2_QueryInterface(shared_factory, riid, (void**)ret);
!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;
}
factory = heap_alloc(sizeof(struct dwritefactory)); factory = heap_alloc(sizeof(struct dwritefactory));
if (!factory) return E_OUTOFMEMORY; if (!factory) return E_OUTOFMEMORY;
...@@ -1337,11 +1330,10 @@ HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnkno ...@@ -1337,11 +1330,10 @@ HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnkno
if (type == DWRITE_FACTORY_TYPE_SHARED) if (type == DWRITE_FACTORY_TYPE_SHARED)
if (InterlockedCompareExchangePointer((void**)&shared_factory, &factory->IDWriteFactory2_iface, NULL)) { if (InterlockedCompareExchangePointer((void**)&shared_factory, &factory->IDWriteFactory2_iface, NULL)) {
release_shared_factory(&factory->IDWriteFactory2_iface); release_shared_factory(&factory->IDWriteFactory2_iface);
*ret = (IUnknown*)shared_factory; return IDWriteFactory2_QueryInterface(shared_factory, riid, (void**)ret);
IDWriteFactory2_AddRef(shared_factory);
return S_OK;
} }
*ret = (IUnknown*)&factory->IDWriteFactory2_iface; hr = IDWriteFactory2_QueryInterface(&factory->IDWriteFactory2_iface, riid, (void**)ret);
return S_OK; IDWriteFactory2_Release(&factory->IDWriteFactory2_iface);
return hr;
} }
...@@ -2312,6 +2312,11 @@ static void test_shared_isolated(void) ...@@ -2312,6 +2312,11 @@ static void test_shared_isolated(void)
hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2); hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown**)&shared2);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(shared == shared2, "got %p, and %p\n", shared, shared2); 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(shared);
IDWriteFactory_Release(shared2); IDWriteFactory_Release(shared2);
...@@ -2330,6 +2335,10 @@ static void test_shared_isolated(void) ...@@ -2330,6 +2335,10 @@ static void test_shared_isolated(void)
ok(isolated != isolated2, "got %p, and %p\n", isolated, isolated2); ok(isolated != isolated2, "got %p, and %p\n", isolated, isolated2);
IDWriteFactory_Release(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); hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED+1, &IID_IDWriteFactory, (IUnknown**)&isolated2);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(shared != isolated2, "got %p, and %p\n", shared, isolated2); ok(shared != isolated2, "got %p, and %p\n", shared, isolated2);
......
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