[PATCH] d3d1x: fix refcounting of GalliumD3D11DeviceChild objects

Christoph Bumiller e0425955 at student.tuwien.ac.at
Mon Sep 19 02:21:38 PDT 2011


---
 .../state_trackers/d3d1x/gd3d11/d3d11_objects.h    |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h
index 7c97632..7b9ee8e 100644
--- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h
+++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_objects.h
@@ -42,6 +42,12 @@ struct GalliumD3D11DeviceChild : public GalliumPrivateDataComObject<Base, dual_r
 		device->AddRef();
 	}
 
+	virtual ~GalliumD3D11DeviceChild()
+	{
+		if (device)
+			device->Release();
+	}
+
 	/* The purpose of this is to avoid cyclic garbage, since this won't hold
 	 * a pointer to the device if it is only held by a pipeline binding in the immediate context
 	 *
@@ -50,13 +56,11 @@ struct GalliumD3D11DeviceChild : public GalliumPrivateDataComObject<Base, dual_r
 	 */
 	inline ULONG add_ref()
 	{
-		device->AddRef();
 		return GalliumPrivateDataComObject<Base, dual_refcnt_t>::add_ref();
 	}
 
 	inline ULONG release()
 	{
-		device->Release();
 		return GalliumPrivateDataComObject<Base, dual_refcnt_t>::release();
 	}
 
-- 
1.7.3.4


--------------020404010103090803050002--


More information about the mesa-dev mailing list