dwrite: Use safer method to set per-factory EUDC collection reference.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-08-22 12:42:13 +03:00 committed by Alexandre Julliard
parent db9990653c
commit f85def7765
1 changed files with 14 additions and 5 deletions

View File

@ -1272,8 +1272,18 @@ static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory5 *ifac
if (This->eudc_collection)
IDWriteFontCollection1_AddRef(This->eudc_collection);
else
hr = get_eudc_fontcollection(iface, &This->eudc_collection);
else {
IDWriteFontCollection1 *eudc_collection;
if (FAILED(hr = get_eudc_fontcollection(iface, &eudc_collection))) {
*collection = NULL;
WARN("Failed to get EUDC collection, hr %#x.\n", hr);
return hr;
}
if (InterlockedCompareExchangePointer((void **)&This->eudc_collection, eudc_collection, NULL))
IDWriteFontCollection1_Release(eudc_collection);
}
*collection = (IDWriteFontCollection *)This->eudc_collection;
@ -1801,8 +1811,7 @@ void factory_detach_fontcollection(IDWriteFactory5 *iface, IDWriteFontCollection
{
struct dwritefactory *factory = impl_from_IDWriteFactory5(iface);
InterlockedCompareExchangePointer((void **)&factory->system_collection, NULL, collection);
if (factory->eudc_collection == collection)
factory->eudc_collection = NULL;
InterlockedCompareExchangePointer((void **)&factory->eudc_collection, NULL, collection);
IDWriteFactory5_Release(iface);
}