From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/comctl32/tests/imagelist.c | 47 ++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 8033a33e9cd..6caea741df8 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -1672,6 +1672,8 @@ static void test_iimagelist(void) HIMAGELIST himl; HRESULT hr; ULONG ret; + HBITMAP hbm; + int ret2;
if (!pHIMAGELIST_QueryInterface) { @@ -1741,7 +1743,50 @@ static void test_iimagelist(void) win_skip("IImageList2 is not supported.\n"); return; } - ok(hr == S_OK, "got 0x%08lx\n", hr); + + hr = IImageList2_Initialize(imagelist, BMP_CX, BMP_CX, ILC_COLOR24, 1, 1); + todo_wine + ok(hr == S_OK, "got %#lx\n", hr); + if (hr != S_OK) return; + + check_iml_data((HIMAGELIST)imagelist, BMP_CX, BMP_CX, 0, 2, 1, ILC_COLOR24, "IImageList2 0"); + + hr = IImageList2_Remove(imagelist, 0); + ok(hr == E_INVALIDARG, "got %#lx\n", hr); + hr = IImageList2_Remove(imagelist, -1); + ok(hr == S_OK, "got %#lx\n", hr); + + hbm = CreateBitmap(BMP_CX, BMP_CX, 1, 1, NULL); + + ret2 = -1; + hr = IImageList2_Add(imagelist, hbm, 0, &ret2); + ok(hr == S_OK, "got %#lx\n", hr); + ok(ret2 == 0, "got %d\n", ret2); + + check_iml_data((HIMAGELIST)imagelist, BMP_CX, BMP_CX, 1, 2, 4, ILC_COLOR24, "IImageList2 1"); + + ret2 = -1; + hr = IImageList2_Add(imagelist, hbm, 0, &ret2); + ok(hr == S_OK, "got %#lx\n", hr); + ok(ret2 == 1, "got %d\n", ret2); + + check_iml_data((HIMAGELIST)imagelist, BMP_CX, BMP_CX, 2, 7, 4, ILC_COLOR24, "IImageList2 2"); + + hr = IImageList2_Remove(imagelist, 0); + ok(hr == S_OK, "got %#lx\n", hr); + + check_iml_data((HIMAGELIST)imagelist, BMP_CX, BMP_CX, 1, 7, 4, ILC_COLOR24, "IImageList2 1"); + + hr = IImageList2_Remove(imagelist, -1); + ok(hr == S_OK, "got %#lx\n", hr); + + check_iml_data((HIMAGELIST)imagelist, BMP_CX, BMP_CX, 0, 4, 1, ILC_COLOR24, "IImageList2 0"); + + hr = IImageList2_Remove(imagelist, 0); + ok(hr == E_INVALIDARG, "got %#lx\n", hr); + + DeleteObject(hbm); + IImageList2_Release(imagelist); }
From: Dmitry Timoshkov dmitry@baikal.ru
... by moving ImageList_Create() implementation.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/comctl32/imagelist.c | 193 ++++++++++++++++---------------- dlls/comctl32/tests/imagelist.c | 2 - 2 files changed, 98 insertions(+), 97 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index 85bb2fe0026..49155e8d2c1 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -763,106 +763,18 @@ HIMAGELIST WINAPI ImageList_Create (INT cx, INT cy, UINT flags, INT cInitial, INT cGrow) { - HIMAGELIST himl; - INT nCount; - HBITMAP hbmTemp; - UINT ilc = (flags & 0xFE); - static const WORD aBitBlend25[] = - {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00}; - - static const WORD aBitBlend50[] = - {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}; + IImageList2 *himl;
TRACE("(%d %d 0x%x %d %d)\n", cx, cy, flags, cInitial, cGrow);
- if (cx < 0 || cy < 0) return NULL; - if (!((flags&ILC_COLORDDB) == ILC_COLORDDB) && (cx == 0 || cy == 0)) return NULL; - /* Create the IImageList interface for the image list */ - if (FAILED(ImageListImpl_CreateInstance(NULL, &IID_IImageList, (void **)&himl))) + if (FAILED(ImageListImpl_CreateInstance(NULL, &IID_IImageList2, (void **)&himl))) return NULL;
- cGrow = (WORD)((max( cGrow, 1 ) + 3) & ~3); - - if (cGrow > 256) - { - /* Windows doesn't limit the size here, but X11 doesn't let us allocate such huge bitmaps */ - WARN( "grow %d too large, limiting to 256\n", cGrow ); - cGrow = 256; - } - - himl->cx = cx; - himl->cy = cy; - himl->flags = flags; - himl->cMaxImage = cInitial + 1; - himl->cInitial = cInitial; - himl->cGrow = cGrow; - himl->clrFg = CLR_DEFAULT; - himl->clrBk = CLR_NONE; - himl->color_table_set = FALSE; - - /* initialize overlay mask indices */ - for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++) - himl->nOvlIdx[nCount] = -1; - - /* Create Image & Mask DCs */ - himl->hdcImage = CreateCompatibleDC (0); - if (!himl->hdcImage) - goto cleanup; - if (himl->flags & ILC_MASK){ - himl->hdcMask = CreateCompatibleDC(0); - if (!himl->hdcMask) - goto cleanup; - } - - /* Default to ILC_COLOR4 if none of the ILC_COLOR* flags are specified */ - if (ilc == ILC_COLOR) - { - ilc = ILC_COLOR4; - himl->flags |= ILC_COLOR4; - } - - if (ilc >= ILC_COLOR4 && ilc <= ILC_COLOR32) - himl->uBitsPixel = ilc; - else - himl->uBitsPixel = (UINT)GetDeviceCaps (himl->hdcImage, BITSPIXEL); - - if (himl->cMaxImage > 0) { - himl->hbmImage = ImageList_CreateImage(himl->hdcImage, himl, himl->cMaxImage); - SelectObject(himl->hdcImage, himl->hbmImage); - } else - himl->hbmImage = 0; - - if ((himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) { - SIZE sz; - - imagelist_get_bitmap_size(himl, himl->cMaxImage, &sz); - himl->hbmMask = CreateBitmap (sz.cx, sz.cy, 1, 1, NULL); - if (himl->hbmMask == 0) { - ERR("Error creating mask bitmap!\n"); - goto cleanup; - } - SelectObject(himl->hdcMask, himl->hbmMask); - } - else - himl->hbmMask = 0; - - himl->item_flags = Alloc( himl->cMaxImage * sizeof(*himl->item_flags) ); - - /* create blending brushes */ - hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend25); - himl->hbrBlend25 = CreatePatternBrush (hbmTemp); - DeleteObject (hbmTemp); - - hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend50); - himl->hbrBlend50 = CreatePatternBrush (hbmTemp); - DeleteObject (hbmTemp); - - TRACE("created imagelist %p\n", himl); - return himl; + if (IImageList2_Initialize(himl, cx, cy, flags, cInitial, cGrow) == S_OK) + return (HIMAGELIST)himl;
-cleanup: - ImageList_Destroy(himl); + IImageList2_Release(himl); return NULL; }
@@ -3721,8 +3633,99 @@ static HRESULT WINAPI ImageListImpl_GetStatistics(IImageList2 *iface, IMAGELISTS
static HRESULT WINAPI ImageListImpl_Initialize(IImageList2 *iface, INT cx, INT cy, UINT flags, INT initial, INT grow) { - FIXME("(%p)->(%d %d %d %d %d): stub\n", iface, cx, cy, flags, initial, grow); - return E_NOTIMPL; + HIMAGELIST himl = impl_from_IImageList2(iface); + INT nCount; + HBITMAP hbmTemp; + UINT ilc = (flags & 0xFE); + static const WORD aBitBlend25[] = + {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00}; + static const WORD aBitBlend50[] = + {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}; + + TRACE("(%p)->(%d %d %d %d %d)\n", iface, cx, cy, flags, initial, grow); + + if (cx < 0 || cy < 0) return E_INVALIDARG; + if (!((flags&ILC_COLORDDB) == ILC_COLORDDB) && (cx == 0 || cy == 0)) return E_INVALIDARG; + + grow = (WORD)((max( grow, 1 ) + 3) & ~3); + + if (grow > 256) + { + /* Windows doesn't limit the size here, but X11 doesn't let us allocate such huge bitmaps */ + WARN( "grow %d too large, limiting to 256\n", grow ); + grow = 256; + } + + himl->cx = cx; + himl->cy = cy; + himl->flags = flags; + himl->cMaxImage = initial + 1; + himl->cInitial = initial; + himl->cGrow = grow; + himl->clrFg = CLR_DEFAULT; + himl->clrBk = CLR_NONE; + himl->color_table_set = FALSE; + + /* initialize overlay mask indices */ + for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++) + himl->nOvlIdx[nCount] = -1; + + /* Create Image & Mask DCs */ + himl->hdcImage = CreateCompatibleDC (0); + if (!himl->hdcImage) + return E_FAIL; + if (himl->flags & ILC_MASK){ + himl->hdcMask = CreateCompatibleDC(0); + if (!himl->hdcMask) + return E_FAIL; + } + + /* Default to ILC_COLOR4 if none of the ILC_COLOR* flags are specified */ + if (ilc == ILC_COLOR) + { + ilc = ILC_COLOR4; + himl->flags |= ILC_COLOR4; + } + + if (ilc >= ILC_COLOR4 && ilc <= ILC_COLOR32) + himl->uBitsPixel = ilc; + else + himl->uBitsPixel = (UINT)GetDeviceCaps (himl->hdcImage, BITSPIXEL); + + if (himl->cMaxImage > 0) { + himl->hbmImage = ImageList_CreateImage(himl->hdcImage, himl, himl->cMaxImage); + SelectObject(himl->hdcImage, himl->hbmImage); + } else + himl->hbmImage = 0; + + if ((himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) { + SIZE sz; + + imagelist_get_bitmap_size(himl, himl->cMaxImage, &sz); + himl->hbmMask = CreateBitmap (sz.cx, sz.cy, 1, 1, NULL); + if (himl->hbmMask == 0) { + ERR("Error creating mask bitmap!\n"); + return E_FAIL; + } + SelectObject(himl->hdcMask, himl->hbmMask); + } + else + himl->hbmMask = 0; + + himl->item_flags = Alloc( himl->cMaxImage * sizeof(*himl->item_flags) ); + + /* create blending brushes */ + hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend25); + himl->hbrBlend25 = CreatePatternBrush (hbmTemp); + DeleteObject (hbmTemp); + + hbmTemp = CreateBitmap (8, 8, 1, 1, aBitBlend50); + himl->hbrBlend50 = CreatePatternBrush (hbmTemp); + DeleteObject (hbmTemp); + + TRACE("created imagelist %p\n", himl); + return S_OK; + }
static HRESULT WINAPI ImageListImpl_Replace2(IImageList2 *iface, INT i, HBITMAP image, HBITMAP mask, IUnknown *unk, DWORD flags) diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 6caea741df8..de0b0dd4c08 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -1745,9 +1745,7 @@ static void test_iimagelist(void) }
hr = IImageList2_Initialize(imagelist, BMP_CX, BMP_CX, ILC_COLOR24, 1, 1); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); - if (hr != S_OK) return;
check_iml_data((HIMAGELIST)imagelist, BMP_CX, BMP_CX, 0, 2, 1, ILC_COLOR24, "IImageList2 0");
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=144067
Your paranoid android.
=== debian11b (64 bit WoW report) ===
d3dx10_34: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001239EA0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011A4A80. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E3560. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 0000000001195800. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011959D0.
d3dx10_35: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001239CF0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011B5D90. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 0000000001239CF0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011C3380. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011C3550.
d3dx10_36: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 0000000001239E40. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011E3500. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E36D0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011E3500. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011BB620.
d3dx10_37: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011C34B0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011C34B0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011BD560. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011B5E50. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 0000000001194020.
d3dx10_38: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011BB560. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011B23C0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E3CC0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011E3CC0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011BB7F0.
d3dx10_39: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011E3AB0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011E3AB0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E3AB0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011BBB50. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011E3C80.
d3dx10_40: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011B24C0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011B23C0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 0000000001239CC0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011BB560. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011BB730.
d3dx10_41: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011B23A0. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011D1AF0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011D1AF0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011BFEB0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011D55F0.
d3dx10_42: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011D5810. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 00000000011C3AB0. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011E35F0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 00000000011E35F0. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011D58D0.
d3dx10_43: d3dx10.c:4380: Test succeeded inside todo block: Got unexpected effect 00000000011C3850. d3dx10.c:4470: Test succeeded inside todo block: Got unexpected effect 0000000001195C00. d3dx10.c:4480: Test succeeded inside todo block: Got unexpected effect 00000000011C34C0. d3dx10.c:4589: Test succeeded inside todo block: Got unexpected effect 0000000001195C00. d3dx10.c:4599: Test succeeded inside todo block: Got unexpected effect 00000000011BBC10.
dmime: Unhandled exception: page fault on read access to 0x0000000000000000 in 64-bit code (0x00000000402d9b).
The only problem I see now is that Initialize() can't be called successfully for already initialized imagelist, on Windows. It does not fail, but following check_iml_data() tests won't work. It probably not worth fixing, if it's broken like that.
This merge request was approved by Nikolay Sivov.