comctl32/imagelist: Make ImageList_Destroy just decrease refcount. Move actual destruction to ::Release.
This commit is contained in:
parent
4afc54540d
commit
7caa61fde6
|
@ -692,25 +692,6 @@ ImageList_Destroy (HIMAGELIST himl)
|
|||
if (!is_valid(himl))
|
||||
return FALSE;
|
||||
|
||||
/* delete image bitmaps */
|
||||
if (himl->hbmImage)
|
||||
DeleteObject (himl->hbmImage);
|
||||
if (himl->hbmMask)
|
||||
DeleteObject (himl->hbmMask);
|
||||
|
||||
/* delete image & mask DCs */
|
||||
if (himl->hdcImage)
|
||||
DeleteDC(himl->hdcImage);
|
||||
if (himl->hdcMask)
|
||||
DeleteDC(himl->hdcMask);
|
||||
|
||||
/* delete blending brushes */
|
||||
if (himl->hbrBlend25)
|
||||
DeleteObject (himl->hbrBlend25);
|
||||
if (himl->hbrBlend50)
|
||||
DeleteObject (himl->hbrBlend50);
|
||||
|
||||
/* Free the IImageList instance */
|
||||
IImageList_Release((IImageList *) himl);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2972,7 +2953,22 @@ static ULONG WINAPI ImageListImpl_Release(IImageList *iface)
|
|||
TRACE("(%p) refcount=%u\n", iface, ref);
|
||||
|
||||
if (ref == 0)
|
||||
{
|
||||
/* delete image bitmaps */
|
||||
if (This->hbmImage) DeleteObject (This->hbmImage);
|
||||
if (This->hbmMask) DeleteObject (This->hbmMask);
|
||||
|
||||
/* delete image & mask DCs */
|
||||
if (This->hdcImage) DeleteDC (This->hdcImage);
|
||||
if (This->hdcMask) DeleteDC (This->hdcMask);
|
||||
|
||||
/* delete blending brushes */
|
||||
if (This->hbrBlend25) DeleteObject (This->hbrBlend25);
|
||||
if (This->hbrBlend50) DeleteObject (This->hbrBlend50);
|
||||
|
||||
This->lpVtbl = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
|
|
@ -1251,8 +1251,36 @@ static void test_iimagelist(void)
|
|||
IImageList *imgl;
|
||||
HIMAGELIST himl;
|
||||
HRESULT hr;
|
||||
ULONG ret;
|
||||
|
||||
if (!pImageList_CoCreateInstance || !pHIMAGELIST_QueryInterface)
|
||||
if (!pHIMAGELIST_QueryInterface)
|
||||
{
|
||||
win_skip("XP imagelist functions not available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* test reference counting on destruction */
|
||||
imgl = (IImageList*)createImageList(32, 32);
|
||||
ret = IUnknown_AddRef(imgl);
|
||||
ok(ret == 2, "Expected 2, got %d\n", ret);
|
||||
ret = ImageList_Destroy((HIMAGELIST)imgl);
|
||||
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
||||
ret = ImageList_Destroy((HIMAGELIST)imgl);
|
||||
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
||||
ret = ImageList_Destroy((HIMAGELIST)imgl);
|
||||
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
|
||||
|
||||
imgl = (IImageList*)createImageList(32, 32);
|
||||
ret = IUnknown_AddRef(imgl);
|
||||
ok(ret == 2, "Expected 2, got %d\n", ret);
|
||||
ret = ImageList_Destroy((HIMAGELIST)imgl);
|
||||
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
||||
ret = IImageList_Release(imgl);
|
||||
ok(ret == 0, "Expected 0, got %d\n", ret);
|
||||
ret = ImageList_Destroy((HIMAGELIST)imgl);
|
||||
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
|
||||
|
||||
if (!pImageList_CoCreateInstance)
|
||||
{
|
||||
win_skip("Vista imagelist functions not available\n");
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue