[PATCH 1/2] ddraw: AddAttachedSurface() just references whatever we pass it.

Henri Verbeet hverbeet at codeweavers.com
Mon Jan 30 14:19:48 CST 2012


---
 dlls/ddraw/surface.c      |   16 ++++++++--------
 dlls/ddraw/tests/ddraw1.c |    4 +++-
 dlls/ddraw/tests/ddraw2.c |    4 +++-
 dlls/ddraw/tests/ddraw4.c |    4 +++-
 dlls/ddraw/tests/ddraw7.c |    4 +++-
 5 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index f4a4d56..ced64a9 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -1605,8 +1605,8 @@ static HRESULT WINAPI ddraw_surface7_AddAttachedSurface(IDirectDrawSurface7 *ifa
     {
         return hr;
     }
-    ddraw_surface7_AddRef(&attachment_impl->IDirectDrawSurface7_iface);
     attachment_impl->attached_iface = (IUnknown *)attachment;
+    IUnknown_AddRef(attachment_impl->attached_iface);
     return hr;
 }
 
@@ -1624,9 +1624,9 @@ static HRESULT WINAPI ddraw_surface4_AddAttachedSurface(IDirectDrawSurface4 *ifa
     {
         return hr;
     }
-    ddraw_surface4_AddRef(&attachment_impl->IDirectDrawSurface4_iface);
-    ddraw_surface7_Release(&attachment_impl->IDirectDrawSurface7_iface);
     attachment_impl->attached_iface = (IUnknown *)attachment;
+    IUnknown_AddRef(attachment_impl->attached_iface);
+    ddraw_surface7_Release(&attachment_impl->IDirectDrawSurface7_iface);
     return hr;
 }
 static HRESULT WINAPI ddraw_surface3_AddAttachedSurface(IDirectDrawSurface3 *iface, IDirectDrawSurface3 *attachment)
@@ -1670,8 +1670,8 @@ static HRESULT WINAPI ddraw_surface3_AddAttachedSurface(IDirectDrawSurface3 *ifa
     {
         return hr;
     }
-    ddraw_surface3_AddRef(&attachment_impl->IDirectDrawSurface3_iface);
     attachment_impl->attached_iface = (IUnknown *)attachment;
+    IUnknown_AddRef(attachment_impl->attached_iface);
     return hr;
 }
 
@@ -1689,9 +1689,9 @@ static HRESULT WINAPI ddraw_surface2_AddAttachedSurface(IDirectDrawSurface2 *ifa
     {
         return hr;
     }
-    ddraw_surface2_AddRef(&attachment_impl->IDirectDrawSurface2_iface);
-    ddraw_surface3_Release(&attachment_impl->IDirectDrawSurface3_iface);
     attachment_impl->attached_iface = (IUnknown *)attachment;
+    IUnknown_AddRef(attachment_impl->attached_iface);
+    ddraw_surface3_Release(&attachment_impl->IDirectDrawSurface3_iface);
     return hr;
 }
 
@@ -1709,9 +1709,9 @@ static HRESULT WINAPI ddraw_surface1_AddAttachedSurface(IDirectDrawSurface *ifac
     {
         return hr;
     }
-    ddraw_surface1_AddRef(&attachment_impl->IDirectDrawSurface_iface);
-    ddraw_surface3_Release(&attachment_impl->IDirectDrawSurface3_iface);
     attachment_impl->attached_iface = (IUnknown *)attachment;
+    IUnknown_AddRef(attachment_impl->attached_iface);
+    ddraw_surface3_Release(&attachment_impl->IDirectDrawSurface3_iface);
     return hr;
 }
 
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 3542564..233d013 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -662,6 +662,7 @@ static void test_surface_interface_mismatch(void)
     IDirect3DMaterial *background = NULL;
     DDSURFACEDESC surface_desc;
     DWORD z_depth = 0;
+    ULONG refcount;
     HRESULT hr;
     D3DCOLOR color;
     HWND window;
@@ -728,7 +729,8 @@ static void test_surface_interface_mismatch(void)
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
     ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
-    IDirectDrawSurface_Release(ds);
+    refcount = IDirectDrawSurface_Release(ds);
+    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 5fa6028..3a62f57 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -687,6 +687,7 @@ static void test_surface_interface_mismatch(void)
     IDirect3DMaterial2 *background = NULL;
     DDSURFACEDESC surface_desc;
     DWORD z_depth = 0;
+    ULONG refcount;
     HRESULT hr;
     D3DCOLOR color;
     HWND window;
@@ -753,7 +754,8 @@ static void test_surface_interface_mismatch(void)
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
     ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
-    IDirectDrawSurface_Release(ds);
+    refcount = IDirectDrawSurface_Release(ds);
+    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 34cab7f..b242f86 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -875,6 +875,7 @@ static void test_surface_interface_mismatch(void)
     IDirect3DViewport3 *viewport = NULL;
     DDSURFACEDESC2 surface_desc;
     DDPIXELFORMAT z_fmt;
+    ULONG refcount;
     HRESULT hr;
     D3DCOLOR color;
     HWND window;
@@ -936,7 +937,8 @@ static void test_surface_interface_mismatch(void)
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
     ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
-    IDirectDrawSurface4_Release(ds);
+    refcount = IDirectDrawSurface4_Release(ds);
+    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 8eb7098..0460a3f 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -841,6 +841,7 @@ static void test_surface_interface_mismatch(void)
     IDirect3DDevice7 *device = NULL;
     DDSURFACEDESC2 surface_desc;
     DDPIXELFORMAT z_fmt;
+    ULONG refcount;
     HRESULT hr;
     D3DCOLOR color;
     HWND window;
@@ -900,7 +901,8 @@ static void test_surface_interface_mismatch(void)
     /* Using a different surface interface version still works */
     hr = IDirectDrawSurface3_AddAttachedSurface(surface3, (IDirectDrawSurface3 *)ds);
     ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
-    IDirectDrawSurface7_Release(ds);
+    refcount = IDirectDrawSurface7_Release(ds);
+    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
     if (FAILED(hr))
         goto cleanup;
 
-- 
1.7.3.4




More information about the wine-patches mailing list