[PATCH 2/2] shell32/iconcache: Break as soon as one shortcut failed to overlay
Huw Davies
huw at codeweavers.com
Thu Nov 29 05:13:14 CST 2018
On Mon, Nov 26, 2018 at 12:22:04PM +0200, Gabriel Ivăncescu wrote:
> There is no need to initialize and destroy shortcut icons that we haven't
> even processed.
>
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
> dlls/shell32/iconcache.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c
> index 44422ab..b9264bb 100644
> --- a/dlls/shell32/iconcache.c
> +++ b/dlls/shell32/iconcache.c
> @@ -361,7 +361,6 @@ static BOOL get_imagelist_icon_size(int list, SIZE *size)
> static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags)
> {
> HICON hicons[ARRAY_SIZE(shell_imagelists)] = { 0 };
> - HICON hshortcuts[ARRAY_SIZE(hicons)] = { 0 };
> unsigned int i;
> SIZE size;
> INT ret = -1;
> @@ -376,6 +375,7 @@ static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags)
>
> if (flags & GIL_FORSHORTCUT)
> {
> + HICON hshortcuts[ARRAY_SIZE(hicons)];
> BOOL failed = FALSE;
>
> for (i = 0; i < ARRAY_SIZE(hshortcuts); i++)
> @@ -384,13 +384,15 @@ static INT SIC_LoadIcon (const WCHAR *sourcefile, INT index, DWORD flags)
> {
> WARN("Failed to create shortcut overlaid icons.\n");
> failed = TRUE;
> + break;
> }
> }
>
> if (failed)
> {
> - for (i = 0; i < ARRAY_SIZE(hshortcuts); i++)
> - DestroyIcon(hshortcuts[i]);
> + unsigned int k;
> + for (k = 0; k < i; k++)
> + DestroyIcon(hshortcuts[k]);
> flags &= ~GIL_FORSHORTCUT;
> }
> else
Rather than optimizing the failure case, we should focus on addressing
the real problem.
Huw.
More information about the wine-devel
mailing list