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;
}
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;
}
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;
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;
}
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;
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;
}