Commit 56d2db81 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Lock wined3d mutex in wined3d_swapchain_decref().

parent aaba7fdd
......@@ -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);
......
......@@ -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)
......
......@@ -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);
}
......
......@@ -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);
}
......
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