From 09e794aff87551b5a50a32121d350f2ad84a2423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Mon, 9 Oct 2006 14:40:30 +0200 Subject: [PATCH] ddraw: Make the ddraw list a wine list. --- dlls/ddraw/ddraw.c | 22 +--------------------- dlls/ddraw/ddraw_private.h | 7 ++++--- dlls/ddraw/main.c | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index a2177d2573..341d936cea 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -62,9 +62,6 @@ static const DDDEVICEIDENTIFIER2 deviceidentifier = 0 }; -/* This is for cleanup if a broken app doesn't Release its objects */ -IDirectDrawImpl *ddraw_list; - /***************************************************************************** * IUnknown Methods *****************************************************************************/ @@ -244,8 +241,6 @@ IDirectDrawImpl_AddRef(IDirectDraw7 *iface) void IDirectDrawImpl_Destroy(IDirectDrawImpl *This) { - IDirectDrawImpl *prev; - /* Clear the cooplevel to restore window and display mode */ IDirectDraw7_SetCooperativeLevel(ICOM_INTERFACE(This, IDirectDraw7), NULL, @@ -262,22 +257,7 @@ IDirectDrawImpl_Destroy(IDirectDrawImpl *This) /* Unregister the window class */ UnregisterClassA(This->classname, 0); - /* Unchain it from the ddraw list */ - if(ddraw_list == This) - { - ddraw_list = This->next; - /* No need to search for a predecessor here */ - } - else - { - for(prev = ddraw_list; prev; prev = prev->next) - if(prev->next == This) break; - - if(prev) - prev->next = This->next; - else - ERR("Didn't find the previous ddraw element in the list\n"); - } + remove_ddraw_object(This); /* Release the attached WineD3D stuff */ IWineD3DDevice_Release(This->wineD3DDevice); diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 5cf9312915..f70da216d5 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -36,6 +36,7 @@ #include "ddcomimpl.h" #include "wine/wined3d_interface.h" +#include "wine/list.h" /***************************************************************************** * IParent - a helper interface @@ -143,7 +144,7 @@ struct IDirectDrawImpl BOOL depthstencil; /* For the dll unload cleanup code */ - IDirectDrawImpl *next; + struct list ddraw_list_entry; LONG surfaces; }; @@ -182,8 +183,8 @@ HRESULT WINAPI IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf, DDSURFACEDESC2 *desc, void *Context); -/* The cleanup list */ -extern IDirectDrawImpl *ddraw_list; +void +remove_ddraw_object(IDirectDrawImpl *ddraw); /* The default surface type */ extern WINED3DSURFTYPE DefaultSurfaceType; diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 3813f14e53..9fbcf3551d 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -58,6 +58,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); /* The configured default surface */ WINED3DSURFTYPE DefaultSurfaceType = SURFACE_UNKNOWN; +static struct list global_ddraw_list = LIST_INIT(global_ddraw_list); + /*********************************************************************** * * Helper function for DirectDrawCreate and friends @@ -302,9 +304,7 @@ DDRAW_Create(GUID *guid, #undef CKEY_CAPS #undef FX_CAPS - /* Add the object to the ddraw cleanup list */ - This->next = ddraw_list; - ddraw_list = This; + list_add_head(&global_ddraw_list, &This->ddraw_list_entry); /* Call QueryInterface to get the pointer to the requested interface. This also initializes * The required refcount @@ -860,16 +860,18 @@ DllMain(HINSTANCE hInstDLL, if(counter == 0) { - if(ddraw_list) + if(!list_empty(&global_ddraw_list)) { - IDirectDrawImpl *ddraw; + struct list *entry, *entry2; WARN("There are still existing DirectDraw interfaces. Wine bug or buggy application?\n"); - for(ddraw = ddraw_list; ddraw; ddraw = ddraw->next) + /* We remove elemets from this loop */ + LIST_FOR_EACH_SAFE(entry, entry2, &global_ddraw_list) { HRESULT hr; DDSURFACEDESC2 desc; int i; + IDirectDrawImpl *ddraw = LIST_ENTRY(entry, IDirectDrawImpl, ddraw_list_entry); WARN("DDraw %p has a refcount of %ld\n", ddraw, ddraw->ref7 + ddraw->ref4 + ddraw->ref2 + ddraw->ref1); @@ -923,3 +925,9 @@ DllMain(HINSTANCE hInstDLL, return TRUE; } + +void +remove_ddraw_object(IDirectDrawImpl *ddraw) +{ + list_remove(&ddraw->ddraw_list_entry); +}