From b8bf0c2628d69952aca59855e155807b6011d5fa Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Tue, 2 May 2017 16:12:35 +0100 Subject: [PATCH] shell32: Simplify imagelist handling. Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/shell32/shell32_main.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/dlls/shell32/shell32_main.c b/dlls/shell32/shell32_main.c index 0ccde93223a..71225916bba 100644 --- a/dlls/shell32/shell32_main.c +++ b/dlls/shell32/shell32_main.c @@ -429,7 +429,6 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, HRESULT hr = S_OK; BOOL IconNotYetLoaded=TRUE; UINT uGilFlags = 0; - HIMAGELIST big_icons, small_icons; TRACE("%s fattr=0x%x sfi=%p(attr=0x%08x) size=0x%x flags=0x%x\n", (flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes, @@ -581,9 +580,6 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, } /* ### icons ###*/ - - Shell_GetImageLists( &big_icons, &small_icons ); - if (flags & SHGFI_OPENICON) uGilFlags |= GIL_OPENICON; @@ -666,6 +662,9 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, /* get icon index (or load icon)*/ if (SUCCEEDED(hr) && (flags & (SHGFI_ICON | SHGFI_SYSICONINDEX))) { + IImageList *icon_list; + SHGetImageList( (flags & SHGFI_SMALLICON) ? SHIL_SMALL : SHIL_LARGE, &IID_IImageList, (void **)&icon_list ); + if (flags & SHGFI_USEFILEATTRIBUTES && !(flags & SHGFI_PIDL)) { WCHAR sTemp [MAX_PATH]; @@ -727,21 +726,14 @@ DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes, } if (ret && (flags & SHGFI_SYSICONINDEX)) { - if (flags & SHGFI_SMALLICON) - ret = (DWORD_PTR)small_icons; - else - ret = (DWORD_PTR)big_icons; - IImageList_AddRef((IImageList*)ret); + IImageList_AddRef( icon_list ); + ret = (DWORD_PTR)icon_list; } - } - - /* icon handle */ - if (SUCCEEDED(hr) && (flags & SHGFI_ICON) && IconNotYetLoaded) - { - if (flags & SHGFI_SMALLICON) - psfi->hIcon = ImageList_GetIcon( small_icons, psfi->iIcon, ILD_NORMAL); - else - psfi->hIcon = ImageList_GetIcon( big_icons, psfi->iIcon, ILD_NORMAL); + if (ret && (flags & SHGFI_ICON)) + { + hr = IImageList_GetIcon( icon_list, psfi->iIcon, ILD_NORMAL, &psfi->hIcon ); + } + IImageList_Release( icon_list ); } if (flags & ~SHGFI_KNOWN_FLAGS)