> Best would be to write a 'DDraw' test (integrated in the test suite) to be
> able to check reference counting in some 'standard' cases (surface
> creation, D3D object creation, ...).
I am afraid this will have to wait a few days, as I don't have access to any 
Windows machine the next days.

> Well, as we call a DDraw 'method' to create the surface, you should add the
> AddRef call there. For the release, it should be in the 'final_release'
> call for the surface (AFAIK, each surface already stores a pointer to its
> parent DDraw object).
How about this one? It increases the refcount in Main_DirectDraw_AddSurface 
and decreases it in Main_DirectDraw_RemoveSurface, the places where the 
surface is attached / removed from the DirectDraw7's surface list.
Index: dlls/ddraw/ddraw_main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/ddraw_main.c,v
retrieving revision 1.8
diff -u -C10 -r1.8 ddraw_main.c
*** dlls/ddraw/ddraw_main.c	26 Jul 2005 20:10:51 -0000	1.8
--- dlls/ddraw/ddraw_main.c	12 Sep 2005 11:02:20 -0000
***************
*** 1296,1315 ****
--- 1296,1316 ----
      return DD_OK;
  }
  
  /*** Owned object management. */
  
  void Main_DirectDraw_AddSurface(IDirectDrawImpl* This,
  				IDirectDrawSurfaceImpl* surface)
  {
      assert(surface->ddraw_owner == NULL || surface->ddraw_owner == This);
  
+     IDirectDraw7_AddRef( (LPDIRECTDRAW7) This );
      surface->ddraw_owner = This;
  
      /* where should it go? */
      surface->next_ddraw = This->surfaces;
      surface->prev_ddraw = NULL;
      if (This->surfaces)
  	This->surfaces->prev_ddraw = surface;
      This->surfaces = surface;
  }
  
***************
*** 1321,1340 ****
--- 1322,1343 ----
      if (This->surfaces == surface)
  	This->surfaces = surface->next_ddraw;
  
      if (This->primary_surface == surface)
  	This->primary_surface = NULL;
  
      if (surface->next_ddraw)
  	surface->next_ddraw->prev_ddraw = surface->prev_ddraw;
      if (surface->prev_ddraw)
  	surface->prev_ddraw->next_ddraw = surface->next_ddraw;
+ 
+     IDirectDraw7_Release( (LPDIRECTDRAW7) This);
  }
  
  static void Main_DirectDraw_DeleteSurfaces(IDirectDrawImpl* This)
  {
      while (This->surfaces != NULL)
  	Main_DirectDrawSurface_ForceDestroy(This->surfaces);
  }
  
  void Main_DirectDraw_AddClipper(IDirectDrawImpl* This,
  				IDirectDrawClipperImpl* clipper)


Reply via email to