shell32: Don't copy the imagelist in SHGetImageList().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2017-04-21 09:49:26 +01:00 committed by Alexandre Julliard
parent 9072dbd2f2
commit 5f0d1a006b
2 changed files with 42 additions and 10 deletions

View File

@ -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);
}
/*************************************************************************

View File

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