Commit 1036ca0d authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

ddraw: Creating surfaces with old interfaces doesn't addref.

parent 68e7ed2c
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment