[9/13] D3D9: AddRef the device in IDirect3DVertexDeclaration9::AddRef

Stefan Dösinger stefan at codeweavers.com
Tue Feb 20 15:48:41 CST 2007


Preparation for fixing the converted declaration reference cycle in the next 
patch
-------------- next part --------------
From 35a93064d2343d9476c9ab26d9ce1d161cb03d4d Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Tue, 20 Feb 2007 18:11:49 +0100
Subject: [PATCH] D3D9: AddRef the device in IDirect3DVertexDeclaration9::AddRef

And create new declarations with ref = 0 and AddRef them before they are returned
---
 dlls/d3d9/vertexdeclaration.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c
index c3f462e..1497a50 100644
--- a/dlls/d3d9/vertexdeclaration.c
+++ b/dlls/d3d9/vertexdeclaration.c
@@ -202,6 +202,10 @@ static ULONG WINAPI IDirect3DVertexDeclaration9Impl_AddRef(LPDIRECT3DVERTEXDECLA
 
     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
 
+    if(ref == 1) {
+        IUnknown_AddRef(This->parentDevice);
+    }
+
     return ref;
 }
 
@@ -323,7 +327,7 @@ HRESULT  WINAPI  IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9
     }
 
     object->lpVtbl = &Direct3DVertexDeclaration9_Vtbl;
-    object->ref = 1;
+    object->ref = 0;
 
     object->elements = HeapAlloc(GetProcessHeap(), 0, element_count * sizeof(D3DVERTEXELEMENT9));
     if (!object->elements) {
@@ -345,9 +349,9 @@ HRESULT  WINAPI  IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9
         FIXME("(%p) call to IWineD3DDevice_CreateVertexDeclaration failed\n", This);
         HeapFree(GetProcessHeap(), 0, object);
     } else {
-        IUnknown_AddRef(iface);
         object->parentDevice = iface;
         *ppDecl = (LPDIRECT3DVERTEXDECLARATION9) object;
+        IUnknown_AddRef(*ppDecl);
          TRACE("(%p) : Created vertex declaration %p\n", This, object);
     }
     return hr;
-- 
1.4.4.3



More information about the wine-patches mailing list