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

This commit is contained in:
Stefan Dösinger 2007-02-16 19:08:09 +01:00 committed by Alexandre Julliard
parent 68e7ed2c90
commit 1036ca0df6
3 changed files with 27 additions and 7 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);