wined3d: Lock wined3d mutex in wined3d_swapchain_decref().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-11-29 14:33:45 +01:00 committed by Alexandre Julliard
parent aaba7fdd00
commit 56d2db81b3
4 changed files with 6 additions and 7 deletions

View file

@ -74,9 +74,7 @@ static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
{
IDirect3DDevice8 *parent_device = swapchain->parent_device;
wined3d_mutex_lock();
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
if (parent_device)
IDirect3DDevice8_Release(parent_device);

View file

@ -124,9 +124,7 @@ static ULONG WINAPI d3d9_swapchain_Release(IDirect3DSwapChain9Ex *iface)
{
IDirect3DDevice9Ex *parent_device = swapchain->parent_device;
wined3d_mutex_lock();
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
if (parent_device)

View file

@ -168,9 +168,7 @@ static ULONG STDMETHODCALLTYPE d3d11_swapchain_Release(IDXGISwapChain1 *iface)
}
if (swapchain->factory)
IDXGIFactory_Release(swapchain->factory);
wined3d_mutex_lock();
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
wined3d_mutex_unlock();
if (device)
IWineDXGIDevice_Release(device);
}

View file

@ -109,17 +109,22 @@ ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
{
ULONG refcount = InterlockedDecrement(&swapchain->ref);
struct wined3d_device *device;
TRACE("%p decreasing refcount to %u.\n", swapchain, refcount);
if (!refcount)
{
struct wined3d_device *device = swapchain->device;
wined3d_mutex_lock();
device = swapchain->device;
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
swapchain_cleanup(swapchain);
swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent);
wined3d_mutex_unlock();
heap_free(swapchain);
}