From 30428604786724b9eb885c952e4713fe34500323 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 18 Oct 2011 20:46:13 +0200 Subject: [PATCH] wined3d: Detach any attached overlays on surface cleanup. Spotted by Dan Kegel / Valgrind. --- dlls/wined3d/surface.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 277a31730e5..1f1dc8feea3 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -42,6 +42,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(struct wined3d_surface *dst_surfa static void surface_cleanup(struct wined3d_surface *surface) { + struct wined3d_surface *overlay, *cur; + TRACE("surface %p.\n", surface); if (surface->texture_name || (surface->flags & SFLAG_PBO) @@ -109,6 +111,12 @@ static void surface_cleanup(struct wined3d_surface *surface) if (surface->overlay_dest) list_remove(&surface->overlay_entry); + LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &surface->overlays, struct wined3d_surface, overlay_entry) + { + list_remove(&overlay->overlay_entry); + overlay->overlay_dest = NULL; + } + HeapFree(GetProcessHeap(), 0, surface->palette9); resource_cleanup(&surface->resource); @@ -1996,6 +2004,8 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface) static void surface_gdi_cleanup(struct wined3d_surface *surface) { + struct wined3d_surface *overlay, *cur; + TRACE("surface %p.\n", surface); if (surface->flags & SFLAG_DIBSECTION) @@ -2014,6 +2024,12 @@ static void surface_gdi_cleanup(struct wined3d_surface *surface) if (surface->overlay_dest) list_remove(&surface->overlay_entry); + LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &surface->overlays, struct wined3d_surface, overlay_entry) + { + list_remove(&overlay->overlay_entry); + overlay->overlay_dest = NULL; + } + HeapFree(GetProcessHeap(), 0, surface->palette9); resource_cleanup(&surface->resource); @@ -3277,6 +3293,7 @@ HRESULT CDECL wined3d_surface_update_overlay(struct wined3d_surface *surface, co if (surface->overlay_dest && (surface->overlay_dest != dst_surface || flags & WINEDDOVER_HIDE)) { + surface->overlay_dest = NULL; list_remove(&surface->overlay_entry); }