d3d8: Don't release the parent device before destroying its children
Allan Tong
actong88 at gmail.com
Mon Sep 28 11:57:57 CDT 2009
-------------- next part --------------
From 96f18c414a66660563980de01bd26c029b2aba86 Mon Sep 17 00:00:00 2001
From: Allan Tong <actong88 at gmail.com>
Date: Mon, 28 Sep 2009 12:50:15 -0400
Subject: d3d8: Don't release the parent device before destroying its children.
---
dlls/d3d8/cubetexture.c | 6 +++++-
dlls/d3d8/indexbuffer.c | 6 +++++-
dlls/d3d8/surface.c | 5 ++++-
dlls/d3d8/texture.c | 6 +++++-
dlls/d3d8/vertexbuffer.c | 6 +++++-
dlls/d3d8/volumetexture.c | 6 +++++-
6 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d8/cubetexture.c b/dlls/d3d8/cubetexture.c
index d3ec98c..24417df 100644
--- a/dlls/d3d8/cubetexture.c
+++ b/dlls/d3d8/cubetexture.c
@@ -64,12 +64,16 @@ static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
+ IDirect3DDevice8 *parentDevice = This->parentDevice;
+
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
- IUnknown_Release(This->parentDevice);
wined3d_mutex_lock();
IWineD3DCubeTexture_Release(This->wineD3DCubeTexture);
wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(parentDevice);
}
return ref;
}
diff --git a/dlls/d3d8/indexbuffer.c b/dlls/d3d8/indexbuffer.c
index 4939122..bb62c39 100644
--- a/dlls/d3d8/indexbuffer.c
+++ b/dlls/d3d8/indexbuffer.c
@@ -64,10 +64,14 @@ static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- IDirect3DDevice8_Release(This->parentDevice);
+ IDirect3DDevice8 *parentDevice = This->parentDevice;
+
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(parentDevice);
}
return ref;
}
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index 2d00fce..8923dd8 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -79,11 +79,14 @@ static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- if (This->parentDevice) IUnknown_Release(This->parentDevice);
+ IDirect3DDevice8 *parentDevice = This->parentDevice;
+
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
wined3d_mutex_unlock();
+
+ if (parentDevice) IDirect3DDevice8_Release(parentDevice);
}
return ref;
diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c
index e377fff..000b078 100644
--- a/dlls/d3d8/texture.c
+++ b/dlls/d3d8/texture.c
@@ -65,10 +65,14 @@ static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- IDirect3DDevice8_Release(This->parentDevice);
+ IDirect3DDevice8 *parentDevice = This->parentDevice;
+
wined3d_mutex_lock();
IWineD3DTexture_Release(This->wineD3DTexture);
wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(parentDevice);
}
return ref;
}
diff --git a/dlls/d3d8/vertexbuffer.c b/dlls/d3d8/vertexbuffer.c
index 99e8304..a798afd 100644
--- a/dlls/d3d8/vertexbuffer.c
+++ b/dlls/d3d8/vertexbuffer.c
@@ -65,10 +65,14 @@ static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- IDirect3DDevice8_Release(This->parentDevice);
+ IDirect3DDevice8 *parentDevice = This->parentDevice;
+
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(parentDevice);
}
return ref;
diff --git a/dlls/d3d8/volumetexture.c b/dlls/d3d8/volumetexture.c
index 46c1ec5..d31c156 100644
--- a/dlls/d3d8/volumetexture.c
+++ b/dlls/d3d8/volumetexture.c
@@ -65,10 +65,14 @@ static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- IUnknown_Release(This->parentDevice);
+ IDirect3DDevice8 *parentDevice = This->parentDevice;
+
wined3d_mutex_lock();
IWineD3DVolumeTexture_Release(This->wineD3DVolumeTexture);
wined3d_mutex_unlock();
+
+ /* Release the device last, as it may cause the device to be destroyed. */
+ IDirect3DDevice8_Release(parentDevice);
}
return ref;
}
--
1.6.0.4
More information about the wine-patches
mailing list