Refcounting fun

Stefan Dösinger stefandoesinger at gmx.at
Sun Feb 12 16:14:00 CST 2006


Hi
> IDirect3DTexure9::Release
> {
>   ULONG ref = This->ref--;
>
>   if(ref == 0)
>   {
>     for(all surfaces in this container)
>     {
>       surfaceImpl->container = NULL;
>       /* Or place this call in WineD3DTexture::Releaase*/
>
>       IWineD3DTexture_Release(This->wineD3DTexture);
>       /* IWineD3DTexture_Release will call the release method
>        * of the IDirect3D9Surface(because it releases the parent),
>        * run the surface's release code(not the container, because
>        * it's set to NULL and destroy the surface, because it's own
>        * refcount is 1 from creation, and we never changed it.
>        * The D3D9 surface release code releases the wineD3DSurface,
>        * and everthing is cleaned.
>        */
>
>        HeapFree(GetProcessHeap, 0, This);
>     }
>   }
> }
Oops, little problem here: That should be

IDirect3DTexure9::Release
{
  ULONG ref = This->ref--;
  if(ref == 0)
  {
    for(all surfaces in this container)
    {
      surfaceImpl->container = NULL;
      /* Don't free the objects in this loop of course ;) */
    }

    /* Or place this call in WineD3DTexture::Releaase*/
    IWineD3DTexture_Release(This->wineD3DTexture);

    /* IWineD3DTexture_Release will call the release method
     * of the IDirect3D9Surface(because it releases the parent),
     * run the surface's release code(not the container, because
     * it's set to NULL and destroy the surface, because it's own
     * refcount is 1 from creation, and we never changed it.
     * The D3D9 surface release code releases the wineD3DSurface,
     * and everthing is cleaned.
     */
     HeapFree(GetProcessHeap, 0, This);
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20060212/9dbbc3ff/attachment.pgp


More information about the wine-devel mailing list