WINED3D: Don't keep a reference to the container.

H. Verbeet hverbeet at gmail.com
Sun Feb 12 08:04:04 CST 2006


As described in my post to wine-devel
(http://www.winehq.org/pipermail/wine-devel/2006-February/044857.html),
keeping a reference to the container causes a circular reference. I
suspect it's also the cause for bug 4521, but can't verify.

Changelog:
  - Don't keep a reference to the container, as it creates a circular reference.
-------------- next part --------------
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index ab25c96..4cb1b3e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -69,9 +69,6 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release
             glDeleteTextures(1, &This->glDescription.textureName);
             LEAVE_GL();
         }
-        if (This->container) {
-            IWineD3DBase_Release(This->container);
-        }
         IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
 
         TRACE("(%p) Released\n", This);
@@ -1357,12 +1354,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetCo
 
     TRACE("This %p, container %p\n", This, container);
 
-    if (container) {
-        IWineD3DBase_AddRef(container);
-    }
-    if (This->container) {
-        IWineD3DBase_Release(This->container);
-    }
+    /* We can't keep a reference to the container, since the container already keeps a reference to us. */
 
     TRACE("Setting container to %p from %p\n", container, This->container);
     This->container = container;
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 0c367bc..3fa1717 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -55,9 +55,6 @@ ULONG WINAPI IWineD3DVolumeImpl_Release(
     TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
     ref = InterlockedDecrement(&This->resource.ref);
     if (ref == 0) {
-        if (This->container) {
-            IWineD3DBase_Release(This->container);
-        }
         IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
         HeapFree(GetProcessHeap(), 0, This);
     }
@@ -252,12 +249,7 @@ HRESULT WINAPI IWineD3DVolumeImpl_SetCon
 
     TRACE("This %p, container %p\n", This, container);
 
-    if (container) {
-        IWineD3DBase_AddRef(container);
-    }
-    if (This->container) {
-        IWineD3DBase_Release(This->container);
-    }
+    /* We can't keep a reference to the container, since the container already keeps a reference to us. */
 
     TRACE("Setting container to %p from %p\n", container, This->container);
     This->container = container;


More information about the wine-patches mailing list