From c7e5e6d2b520312320a18b447472b0b8d32d295e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ri=C4=8Dardas=20Barkauskas?= Date: Tue, 28 Jun 2011 01:06:16 +0300 Subject: [PATCH] ddraw: Use ddraw_surface_release_iface to destroy leftover surfaces. --- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/main.c | 7 +++---- dlls/ddraw/surface.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index e15219df527..1a8dc2025f8 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -212,6 +212,7 @@ HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface) DECLSPEC_H void ddraw_surface_destroy(IDirectDrawSurfaceImpl *surface) DECLSPEC_HIDDEN; HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw, DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type, UINT version) DECLSPEC_HIDDEN; +ULONG ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This) DECLSPEC_HIDDEN; static inline IDirectDrawSurfaceImpl *surface_from_texture1(IDirect3DTexture *iface) { diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 36c0ef73e0b..37404d82064 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -752,7 +752,7 @@ DestroyCallback(IDirectDrawSurface7 *surf, void *context) { IDirectDrawSurfaceImpl *Impl = impl_from_IDirectDrawSurface7(surf); - ULONG ref, ref3, ref2; + ULONG ref, ref3, ref2, iface_count; ref = IDirectDrawSurface7_Release(surf); /* For the EnumSurfaces */ IDirectDrawSurface3_AddRef(&Impl->IDirectDrawSurface3_iface); @@ -769,9 +769,8 @@ DestroyCallback(IDirectDrawSurface7 *surf, return DDENUMRET_OK; /* Destroy the surface */ - while (ref) ref = IDirectDrawSurface7_Release(surf); - while (ref3) ref3 = IDirectDrawSurface3_Release(&Impl->IDirectDrawSurface3_iface); - while (ref2) ref2 = IDirectDrawSurface2_Release(&Impl->IDirectDrawSurface2_iface); + iface_count = ddraw_surface_release_iface(Impl); + while (iface_count) iface_count = ddraw_surface_release_iface(Impl); return DDENUMRET_OK; } diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 102aa55162d..e391b3d5e14 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -449,7 +449,7 @@ static void ddraw_surface_cleanup(IDirectDrawSurfaceImpl *surface) IUnknown_Release(ifaceToRelease); } -static void ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This) +ULONG ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This) { ULONG iface_count = InterlockedDecrement(&This->iface_count); TRACE("%p decreasing iface count to %u.\n", This, iface_count); @@ -462,7 +462,7 @@ static void ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This) { WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This); LeaveCriticalSection(&ddraw_cs); - return; + return iface_count; } if (This->wined3d_texture) /* If it's a texture, destroy the wined3d texture. */ wined3d_texture_decref(This->wined3d_texture); @@ -471,7 +471,7 @@ static void ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This) LeaveCriticalSection(&ddraw_cs); } - return; + return iface_count; } /*****************************************************************************