[6/10] DDraw: Creating surfaces with old interfaces doesn't addref
Stefan Dösinger
stefan at codeweavers.com
Fri Feb 16 12:08:09 CST 2007
-------------- next part --------------
From b8d2150c1c696d4780fa5f6b2c02976df30635c5 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Tue, 13 Feb 2007 16:30:50 +0100
Subject: [PATCH] DDraw: Creating surfaces with old interfaces doesn't addref
---
dlls/ddraw/ddraw_thunks.c | 6 ++----
dlls/ddraw/surface.c | 2 +-
dlls/ddraw/tests/refcount.c | 26 ++++++++++++++++++++++++--
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/dlls/ddraw/ddraw_thunks.c b/dlls/ddraw/ddraw_thunks.c
index ce61f18..964466d 100644
--- a/dlls/ddraw/ddraw_thunks.c
+++ b/dlls/ddraw/ddraw_thunks.c
@@ -410,8 +410,7 @@ IDirectDrawImpl_CreateSurface(LPDIRECTDRAW This, LPDDSURFACEDESC pSDesc,
IDirectDraw,
IDirectDraw7,
This));
- IDirectDraw_AddRef(This);
- impl->ifaceToRelease = (IUnknown *) This;
+ impl->ifaceToRelease = NULL;
}
return hr;
@@ -446,8 +445,7 @@ IDirectDraw2Impl_CreateSurface(LPDIRECTDRAW2 This, LPDDSURFACEDESC pSDesc,
IDirectDraw2,
IDirectDraw7,
This));
- IDirectDraw2_AddRef(This);
- impl->ifaceToRelease = (IUnknown *) This;
+ impl->ifaceToRelease = NULL;
}
return hr;
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index cd35832..c41d08f 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -376,7 +376,7 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
IDirectDrawSurfaceImpl_Destroy(This);
/* Reduce the ddraw refcount */
- IUnknown_Release(ifaceToRelease);
+ if(ifaceToRelease) IUnknown_Release(ifaceToRelease);
}
return ref;
diff --git a/dlls/ddraw/tests/refcount.c b/dlls/ddraw/tests/refcount.c
index b79612f..11301d3 100644
--- a/dlls/ddraw/tests/refcount.c
+++ b/dlls/ddraw/tests/refcount.c
@@ -49,10 +49,12 @@ static void test_ddraw_objects(void)
unsigned long ref;
IDirectDraw7 *DDraw7;
IDirectDraw4 *DDraw4;
- IDirectDraw4 *DDraw2;
- IDirectDraw4 *DDraw1;
+ IDirectDraw2 *DDraw2;
+ IDirectDraw *DDraw1;
IDirectDrawPalette *palette;
IDirectDrawSurface7 *surface;
+ IDirectDrawSurface *surface1;
+ IDirectDrawSurface4 *surface4;
PALETTEENTRY Table[256];
DDSURFACEDESC2 ddsd;
@@ -163,6 +165,26 @@ static void test_ddraw_objects(void)
ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
IDirectDrawPalette_Release(palette);
+ /* Simmilar for surfaces */
+ hr = IDirectDraw4_CreateSurface(DDraw4, &ddsd, &surface4, NULL);
+ ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+ ref = getRefcount( (IUnknown *) DDraw4);
+ ok(ref == 2, "Got refcount %ld, expected 2\n", ref);
+ IDirectDrawSurface4_Release(surface4);
+
+ ddsd.dwSize = sizeof(DDSURFACEDESC);
+ hr = IDirectDraw2_CreateSurface(DDraw2, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
+ ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+ ref = getRefcount( (IUnknown *) DDraw2);
+ ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
+ IDirectDrawSurface_Release(surface1);
+
+ hr = IDirectDraw_CreateSurface(DDraw1, (DDSURFACEDESC *) &ddsd, &surface1, NULL);
+ ok(hr == DD_OK, "CreateSurface returned %08x\n", hr);
+ ref = getRefcount( (IUnknown *) DDraw1);
+ ok(ref == 1, "Got refcount %ld, expected 1\n", ref);
+ IDirectDrawSurface_Release(surface1);
+
IDirectDraw7_Release(DDraw7);
IDirectDraw4_Release(DDraw4);
IDirectDraw2_Release(DDraw2);
--
1.4.4.3
More information about the wine-patches
mailing list