Commit 09e794af authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: Make the ddraw list a wine list.

parent 9eda99c0
...@@ -62,9 +62,6 @@ static const DDDEVICEIDENTIFIER2 deviceidentifier = ...@@ -62,9 +62,6 @@ static const DDDEVICEIDENTIFIER2 deviceidentifier =
0 0
}; };
/* This is for cleanup if a broken app doesn't Release its objects */
IDirectDrawImpl *ddraw_list;
/***************************************************************************** /*****************************************************************************
* IUnknown Methods * IUnknown Methods
*****************************************************************************/ *****************************************************************************/
...@@ -244,8 +241,6 @@ IDirectDrawImpl_AddRef(IDirectDraw7 *iface) ...@@ -244,8 +241,6 @@ IDirectDrawImpl_AddRef(IDirectDraw7 *iface)
void void
IDirectDrawImpl_Destroy(IDirectDrawImpl *This) IDirectDrawImpl_Destroy(IDirectDrawImpl *This)
{ {
IDirectDrawImpl *prev;
/* Clear the cooplevel to restore window and display mode */ /* Clear the cooplevel to restore window and display mode */
IDirectDraw7_SetCooperativeLevel(ICOM_INTERFACE(This, IDirectDraw7), IDirectDraw7_SetCooperativeLevel(ICOM_INTERFACE(This, IDirectDraw7),
NULL, NULL,
...@@ -262,22 +257,7 @@ IDirectDrawImpl_Destroy(IDirectDrawImpl *This) ...@@ -262,22 +257,7 @@ IDirectDrawImpl_Destroy(IDirectDrawImpl *This)
/* Unregister the window class */ /* Unregister the window class */
UnregisterClassA(This->classname, 0); UnregisterClassA(This->classname, 0);
/* Unchain it from the ddraw list */ remove_ddraw_object(This);
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");
}
/* Release the attached WineD3D stuff */ /* Release the attached WineD3D stuff */
IWineD3DDevice_Release(This->wineD3DDevice); IWineD3DDevice_Release(This->wineD3DDevice);
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "ddcomimpl.h" #include "ddcomimpl.h"
#include "wine/wined3d_interface.h" #include "wine/wined3d_interface.h"
#include "wine/list.h"
/***************************************************************************** /*****************************************************************************
* IParent - a helper interface * IParent - a helper interface
...@@ -143,7 +144,7 @@ struct IDirectDrawImpl ...@@ -143,7 +144,7 @@ struct IDirectDrawImpl
BOOL depthstencil; BOOL depthstencil;
/* For the dll unload cleanup code */ /* For the dll unload cleanup code */
IDirectDrawImpl *next; struct list ddraw_list_entry;
LONG surfaces; LONG surfaces;
}; };
...@@ -182,8 +183,8 @@ HRESULT WINAPI ...@@ -182,8 +183,8 @@ HRESULT WINAPI
IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf, IDirectDrawImpl_RecreateSurfacesCallback(IDirectDrawSurface7 *surf,
DDSURFACEDESC2 *desc, DDSURFACEDESC2 *desc,
void *Context); void *Context);
/* The cleanup list */ void
extern IDirectDrawImpl *ddraw_list; remove_ddraw_object(IDirectDrawImpl *ddraw);
/* The default surface type */ /* The default surface type */
extern WINED3DSURFTYPE DefaultSurfaceType; extern WINED3DSURFTYPE DefaultSurfaceType;
......
...@@ -58,6 +58,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); ...@@ -58,6 +58,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* The configured default surface */ /* The configured default surface */
WINED3DSURFTYPE DefaultSurfaceType = SURFACE_UNKNOWN; WINED3DSURFTYPE DefaultSurfaceType = SURFACE_UNKNOWN;
static struct list global_ddraw_list = LIST_INIT(global_ddraw_list);
/*********************************************************************** /***********************************************************************
* *
* Helper function for DirectDrawCreate and friends * Helper function for DirectDrawCreate and friends
...@@ -302,9 +304,7 @@ DDRAW_Create(GUID *guid, ...@@ -302,9 +304,7 @@ DDRAW_Create(GUID *guid,
#undef CKEY_CAPS #undef CKEY_CAPS
#undef FX_CAPS #undef FX_CAPS
/* Add the object to the ddraw cleanup list */ list_add_head(&global_ddraw_list, &This->ddraw_list_entry);
This->next = ddraw_list;
ddraw_list = This;
/* Call QueryInterface to get the pointer to the requested interface. This also initializes /* Call QueryInterface to get the pointer to the requested interface. This also initializes
* The required refcount * The required refcount
...@@ -860,16 +860,18 @@ DllMain(HINSTANCE hInstDLL, ...@@ -860,16 +860,18 @@ DllMain(HINSTANCE hInstDLL,
if(counter == 0) 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"); 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; HRESULT hr;
DDSURFACEDESC2 desc; DDSURFACEDESC2 desc;
int i; 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); 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, ...@@ -923,3 +925,9 @@ DllMain(HINSTANCE hInstDLL,
return TRUE; return TRUE;
} }
void
remove_ddraw_object(IDirectDrawImpl *ddraw)
{
list_remove(&ddraw->ddraw_list_entry);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment