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) ...@@ -2226,25 +2226,51 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
HBITMAP hbmOldSrc; HBITMAP hbmOldSrc;
ICONINFO ii; ICONINFO ii;
BITMAP bmp; BITMAP bmp;
BOOL ret;
TRACE("(%p %d %p)\n", himl, i, hIcon); TRACE("(%p %d %p)\n", himl, i, hIcon);
if (!is_valid(himl)) if (!is_valid(himl)) {
return -1; ERR("invalid image list\n");
if ((i >= himl->cMaxImage) || (i < -1)) return -1;
return -1; }
if ((i >= himl->cMaxImage) || (i < -1)) {
ERR("invalid image index %d / %d\n", i, himl->cMaxImage);
return -1;
}
hBestFitIcon = CopyImage( hBestFitIcon = CopyImage(
hIcon, IMAGE_ICON, hIcon, IMAGE_ICON,
himl->cx, himl->cy, himl->cx, himl->cy,
LR_COPYFROMRESOURCE); 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) if (ii.hbmColor == 0)
ERR("no color!\n"); 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 (i == -1) {
if (himl->cCurImage + 1 > himl->cMaxImage) if (himl->cCurImage + 1 > himl->cMaxImage)
...@@ -2276,8 +2302,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon) ...@@ -2276,8 +2302,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
SelectObject (hdcImage, hbmOldSrc); SelectObject (hdcImage, hbmOldSrc);
if(hBestFitIcon) DestroyIcon(hBestFitIcon);
DestroyIcon(hBestFitIcon);
if (hdcImage) if (hdcImage)
DeleteDC (hdcImage); DeleteDC (hdcImage);
if (ii.hbmColor) if (ii.hbmColor)
......
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