From: Zhiyi Zhang zzhang@codeweavers.com
Use a magic value to check if an image list is valid instead of using vtable addresses. So that an image list from comctl32 v5 can be used with comctl32 v6 image list functions and vice versa.
Fix missing icons in the listview window of the Word 2010 file open dialog. --- dlls/comctl32/imagelist.c | 5 ++++- dlls/comctl32/tests/imagelist.c | 6 ------ 2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c index 493aebd0b45..93c502ec0bd 100644 --- a/dlls/comctl32/imagelist.c +++ b/dlls/comctl32/imagelist.c @@ -71,6 +71,7 @@ struct _IMAGELIST INT nOvlIdx[MAX_OVERLAYIMAGE]; /* 38: overlay images index */
/* not yet found out */ + DWORD magic; HBRUSH hbrBlend25; HBRUSH hbrBlend50; INT cInitial; @@ -3214,6 +3215,7 @@ static ULONG WINAPI ImageListImpl_Release(IImageList2 *iface) if (This->hbrBlend50) DeleteObject (This->hbrBlend50);
This->IImageList2_iface.lpVtbl = NULL; + This->magic = 0; Free(This->item_flags); Free(This); } @@ -3797,7 +3799,7 @@ static BOOL is_valid(HIMAGELIST himl) BOOL valid; __TRY { - valid = himl && himl->IImageList2_iface.lpVtbl == &ImageListImpl_Vtbl; + valid = himl && himl->magic == IMAGELIST_MAGIC; } __EXCEPT_PAGE_FAULT { @@ -3844,6 +3846,7 @@ static HRESULT ImageListImpl_CreateInstance(const IUnknown *pUnkOuter, REFIID ii if (!This) return E_OUTOFMEMORY;
This->IImageList2_iface.lpVtbl = &ImageListImpl_Vtbl; + This->magic = IMAGELIST_MAGIC; This->ref = 1;
ret = IImageList2_QueryInterface(&This->IImageList2_iface, iid, ppv); diff --git a/dlls/comctl32/tests/imagelist.c b/dlls/comctl32/tests/imagelist.c index 8647fd5a62a..c8a1a25b71d 100644 --- a/dlls/comctl32/tests/imagelist.c +++ b/dlls/comctl32/tests/imagelist.c @@ -2938,13 +2938,10 @@ static void test_imagelist_interop(void) cx = 0; cy = 0; ret = pImageList_GetIconSize(himl, &cx, &cy); - todo_wine ok(ret, "ImageList_GetIconSize failed.\n"); - todo_wine ok(cx == 1 && cy == 1, "Got unexpected size %dx%d.\n", cx, cy);
ret = pImageList_Destroy(himl); - todo_wine ok(ret, "ImageList_Destroy failed.\n");
/* Create a v6 imagelist and use it with v5 imagelist functions */ @@ -2954,13 +2951,10 @@ static void test_imagelist_interop(void) cx = 0; cy = 0; ret = pImageList_GetIconSize_v5(himl, &cx, &cy); - todo_wine ok(ret, "ImageList_GetIconSize failed.\n"); - todo_wine ok(cx == 1 && cy == 1, "Got unexpected size %dx%d.\n", cx, cy);
ret = pImageList_Destroy_v5(himl); - todo_wine ok(ret, "ImageList_Destroy failed.\n");
FreeLibrary(comctl32_v5);