Commit ec167634 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Handle CopyImage and other functions failing by not adding the icon

and notifying the caller.
parent 31acf7f5
......@@ -2226,25 +2226,51 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
HBITMAP hbmOldSrc;
ICONINFO ii;
BITMAP bmp;
BOOL ret;
TRACE("(%p %d %p)\n", himl, i, hIcon);
if (!is_valid(himl))
if (!is_valid(himl)) {
ERR("invalid image list\n");
return -1;
if ((i >= himl->cMaxImage) || (i < -1))
}
if ((i >= himl->cMaxImage) || (i < -1)) {
ERR("invalid image index %d / %d\n", i, himl->cMaxImage);
return -1;
}
hBestFitIcon = CopyImage(
hIcon, IMAGE_ICON,
himl->cx, himl->cy,
LR_COPYFROMRESOURCE);
/* the above will fail if the icon wasn't loaded from a resource, so try
* again without LR_COPYFROMRESOURCE flag */
if (!hBestFitIcon)
hBestFitIcon = CopyImage(
hIcon, IMAGE_ICON,
himl->cx, himl->cy,
0);
if (!hBestFitIcon)
return -1;
ret = GetIconInfo (hBestFitIcon, &ii);
if (!ret) {
DestroyIcon(hBestFitIcon);
return -1;
}
GetIconInfo (hBestFitIcon, &ii);
if (ii.hbmMask == 0)
ERR("no mask!\n");
if (ii.hbmColor == 0)
ERR("no color!\n");
GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
ret = GetObjectW (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp);
if (!ret) {
ERR("couldn't get mask bitmap info\n");
if (ii.hbmColor)
DeleteObject (ii.hbmColor);
if (ii.hbmMask)
DeleteObject (ii.hbmMask);
DestroyIcon(hBestFitIcon);
return -1;
}
if (i == -1) {
if (himl->cCurImage + 1 > himl->cMaxImage)
......@@ -2276,7 +2302,6 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
SelectObject (hdcImage, hbmOldSrc);
if(hBestFitIcon)
DestroyIcon(hBestFitIcon);
if (hdcImage)
DeleteDC (hdcImage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment