From 805981333779063656e673ed3346031a1de6faff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 4 Jan 2023 21:25:45 +0530 Subject: [PATCH] ... --- src/calibre/utils/windows/winutil.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/utils/windows/winutil.cpp b/src/calibre/utils/windows/winutil.cpp index 75147eac71..e03e3a2fce 100644 --- a/src/calibre/utils/windows/winutil.cpp +++ b/src/calibre/utils/windows/winutil.cpp @@ -1111,7 +1111,8 @@ get_icon_at_index(int shilsize, int index) { IImageListPtr spiml; HRESULT hr = SHGetImageList(shilsize, IID_PPV_ARGS(&spiml)); HICON hico = NULL; - if (SUCCEEDED(hr)) spiml->GetIcon(index, ILD_TRANSPARENT, &hico); + if (SUCCEEDED(hr)) spiml->GetIcon(index, ILD_TRANSPARENT | ILD_IMAGE, &hico); + spiml->Release(); return hico; } @@ -1130,14 +1131,14 @@ get_icon_for_file(PyObject *self, PyObject *args) { HICON icon; #define R(shil) { \ Py_BEGIN_ALLOW_THREADS \ - icon = get_icon_at_index(SHIL_JUMBO, fi.iIcon); \ + icon = get_icon_at_index(shil, fi.iIcon); \ Py_END_ALLOW_THREADS \ if (icon) return (PyObject*)Handle_create(icon, IconHandle); \ } R(SHIL_JUMBO); R(SHIL_EXTRALARGE); R(SHIL_LARGE); R(SHIL_SYSSMALL); R(SHIL_SMALL); #undef R return PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, ERROR_RESOURCE_TYPE_NOT_FOUND, PyTuple_GET_ITEM(args, 0)); -} // }}} +} static PyObject* @@ -1165,7 +1166,7 @@ get_bitmap_for_file(PyObject *self, PyObject *args) { return error_from_hresult(hr, "Failed to get image from shell item"); } return (PyObject*)Handle_create(hbmp, BitmapHandle); -} +} // }}} // Boilerplate {{{ static const char winutil_doc[] = "Defines utility methods to interface with windows.";