Stefan Dösinger : ddraw: Make the ddraw list a wine list.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Oct 9 14:05:08 CDT 2006


Module: wine
Branch: master
Commit: 09e794aff87551b5a50a32121d350f2ad84a2423
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=09e794aff87551b5a50a32121d350f2ad84a2423

Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date:   Mon Oct  9 14:40:30 2006 +0200

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 a2177d2..341d936 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -62,9 +62,6 @@ static const DDDEVICEIDENTIFIER2 devicei
     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 *ifa
 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 
     /* 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 5cf9312..f70da21 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -36,6 +36,7 @@ #include "d3d.h"
 #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 3813f14..9fbcf35 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 @@ #undef BLIT_CAPS
 #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);
+}




More information about the wine-cvs mailing list