From a538d28f28308b08d700c1c4d1c84b08d3ee4861 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 28 Jan 2011 20:05:40 +0100 Subject: [PATCH] wined3d: Set color / depth / stencil surfaces to NULL before releasing them in IWineD3DDeviceImpl_Uninit3D(). --- dlls/wined3d/device.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 676eafce277..d5ae431ce0e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2112,6 +2112,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; const struct wined3d_gl_info *gl_info; + struct IWineD3DSurfaceImpl *surface; struct wined3d_context *context; int sampler; UINT i; @@ -2200,21 +2201,32 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, /* Release the buffers (with sanity checks)*/ if (This->onscreen_depth_stencil) { - IWineD3DSurface_Release((IWineD3DSurface *)This->onscreen_depth_stencil); + surface = This->onscreen_depth_stencil; This->onscreen_depth_stencil = NULL; + IWineD3DSurface_Release((IWineD3DSurface *)surface); } if (This->depth_stencil) { - IWineD3DSurfaceImpl *ds = This->depth_stencil; + surface = This->depth_stencil; - TRACE("Releasing depth/stencil buffer %p.\n", ds); + TRACE("Releasing depth/stencil buffer %p.\n", surface); This->depth_stencil = NULL; - if (IWineD3DSurface_Release((IWineD3DSurface *)ds) - && ds != This->auto_depth_stencil) + if (IWineD3DSurface_Release((IWineD3DSurface *)surface) + && surface != This->auto_depth_stencil) { - ERR("Something is still holding a reference to depth/stencil buffer %p.\n", ds); + ERR("Something is still holding a reference to depth/stencil buffer %p.\n", surface); + } + } + + if (This->auto_depth_stencil) + { + surface = This->auto_depth_stencil; + This->auto_depth_stencil = NULL; + if (IWineD3DSurface_Release((IWineD3DSurface *)surface)) + { + FIXME("(%p) Something's still holding the auto depth stencil buffer\n", This); } } @@ -2223,20 +2235,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, IWineD3DDevice_SetRenderTarget(iface, i, NULL, FALSE); } - TRACE("Releasing the render target at %p\n", This->render_targets[0]); - IWineD3DSurface_Release((IWineD3DSurface *)This->render_targets[0]); - - TRACE("Setting rendertarget to NULL\n"); + surface = This->render_targets[0]; + TRACE("Setting rendertarget 0 to NULL\n"); This->render_targets[0] = NULL; - - if (This->auto_depth_stencil) - { - if (IWineD3DSurface_Release((IWineD3DSurface *)This->auto_depth_stencil)) - { - FIXME("(%p) Something's still holding the auto depth stencil buffer\n", This); - } - This->auto_depth_stencil = NULL; - } + TRACE("Releasing the render target at %p\n", surface); + IWineD3DSurface_Release((IWineD3DSurface *)surface); context_release(context);