Module: wine Branch: master Commit: 5f0d1a006bf02e22893355f001641ac24046f9b0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5f0d1a006bf02e22893355f001...
Author: Huw Davies huw@codeweavers.com Date: Fri Apr 21 09:49:26 2017 +0100
shell32: Don't copy the imagelist in SHGetImageList().
Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/shell32/shellord.c | 12 ++---------- dlls/shell32/tests/shelllink.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c index 1a67a52..96dd33a 100644 --- a/dlls/shell32/shellord.c +++ b/dlls/shell32/shellord.c @@ -2182,7 +2182,6 @@ HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv) { HIMAGELIST hLarge, hSmall; HIMAGELIST hNew; - HRESULT ret = E_FAIL;
/* Wine currently only maintains large and small image lists */ if ((iImageList != SHIL_LARGE) && (iImageList != SHIL_SMALL) && (iImageList != SHIL_SYSSMALL)) @@ -2192,16 +2191,9 @@ HRESULT WINAPI SHGetImageList(int iImageList, REFIID riid, void **ppv) }
Shell_GetImageLists(&hLarge, &hSmall); - hNew = ImageList_Duplicate(iImageList == SHIL_LARGE ? hLarge : hSmall); + hNew = (iImageList == SHIL_LARGE) ? hLarge : hSmall;
- /* Get the interface for the new image list */ - if (hNew) - { - ret = HIMAGELIST_QueryInterface(hNew, riid, ppv); - ImageList_Destroy(hNew); - } - - return ret; + return HIMAGELIST_QueryInterface(hNew, riid, ppv); }
/************************************************************************* diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c index c88e344..db15ccd 100644 --- a/dlls/shell32/tests/shelllink.c +++ b/dlls/shell32/tests/shelllink.c @@ -27,6 +27,7 @@ #include "shobjidl.h" #include "shlobj.h" #include "shellapi.h" +#include "commoncontrols.h" #include "wine/test.h"
#include "shell32_test.h" @@ -1303,6 +1304,44 @@ todo_wine { DestroyIcon(hicon); }
+static void test_SHGetImageList(void) +{ + HRESULT hr; + IImageList *list, *list2; + BOOL ret; + HIMAGELIST lg, sm; + ULONG start_refs, refs; + + hr = SHGetImageList( SHIL_LARGE, &IID_IImageList, (void **)&list ); + ok( hr == S_OK, "got %08x\n", hr ); + start_refs = IImageList_AddRef( list ); + IImageList_Release( list ); + + hr = SHGetImageList( SHIL_LARGE, &IID_IImageList, (void **)&list2 ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( list == list2, "lists differ\n" ); + refs = IImageList_AddRef( list ); + IImageList_Release( list ); + ok( refs == start_refs + 1, "got %d, start_refs %d\n", refs, start_refs ); + IImageList_Release( list2 ); + + hr = SHGetImageList( SHIL_SMALL, &IID_IImageList, (void **)&list2 ); + ok( hr == S_OK, "got %08x\n", hr ); + + ret = Shell_GetImageLists( &lg, &sm ); + ok( ret, "got %d\n", ret ); + ok( lg == (HIMAGELIST)list, "mismatch\n" ); + ok( sm == (HIMAGELIST)list2, "mismatch\n" ); + + /* Shell_GetImageLists doesn't take a reference */ + refs = IImageList_AddRef( list ); + IImageList_Release( list ); + ok( refs == start_refs, "got %d, start_refs %d\n", refs, start_refs ); + + IImageList_Release( list2 ); + IImageList_Release( list ); +} + START_TEST(shelllink) { HRESULT r; @@ -1333,6 +1372,7 @@ START_TEST(shelllink) test_propertystore(); test_ExtractIcon(); test_ExtractAssociatedIcon(); + test_SHGetImageList();
CoUninitialize(); }