ddraw: Make the ddraw list a wine list.

This commit is contained in:
Stefan Dösinger 2006-10-09 14:40:30 +02:00 committed by Alexandre Julliard
parent 9eda99c0bb
commit 09e794aff8
3 changed files with 19 additions and 30 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);
}