summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXDraw.c7
-rw-r--r--macosx/tkMacOSXWm.c11
-rw-r--r--tests/wm.test6
-rw-r--r--unix/tkUnixWm.c4
-rw-r--r--win/tkWinWm.c4
5 files changed, 25 insertions, 7 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index b10246a..6a4890c 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -501,9 +501,12 @@ TkMacOSXGetNSImageWithTkImage(
int width,
int height)
{
- Pixmap pixmap = Tk_GetPixmap(display, None, width, height, 0);
+ Pixmap pixmap;
NSImage *nsImage;
-
+ if (width == 0 | height == 0) {
+ return nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0,0)];
+ }
+ pixmap = Tk_GetPixmap(display, None, width, height, 0);
Tk_RedrawImage(image, 0, 0, width, height, pixmap, 0, 0);
nsImage = CreateNSImageWithPixmap(pixmap, width, height);
Tk_FreePixmap(display, pixmap);
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 6cf1b53..4e53282 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -2518,6 +2518,7 @@ WmIconphotoCmd(
{
Tk_Image tk_icon;
int width, height, isDefault = 0;
+ NSImage *newIcon = NULL;
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -2563,12 +2564,16 @@ WmIconphotoCmd(
return TCL_ERROR;
}
- NSImage *newIcon;
Tk_SizeOfImage(tk_icon, &width, &height);
- newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon,
- width, height);
+ if (width != 0 && height != 0) {
+ newIcon = TkMacOSXGetNSImageWithTkImage(winPtr->display, tk_icon,
+ width, height);
+ }
Tk_FreeImage(tk_icon);
if (newIcon == NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create an iconphoto with image \"%s\"", icon));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}
[NSApp setApplicationIconImage: newIcon];
diff --git a/tests/wm.test b/tests/wm.test
index 7ba02e3..2978c1b 100644
--- a/tests/wm.test
+++ b/tests/wm.test
@@ -873,6 +873,12 @@ test wm-iconphoto-1.4 {usage} -returnCodes error -body {
# we currently have no return info
wm iconphoto . -default
} -result {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}
+test wm-iconphoto-1.5.1 {usage} -constraints aquaOrWin32 -returnCodes error -body {
+ wm iconphoto . -default [image create photo -file {}]
+} -match {glob} -result {failed to create an iconphoto with image *}
+test wm-iconphoto-1.5.2 {usage} -constraints x11 -body {
+ wm iconphoto . -default [image create photo -file {}]
+} -result {}
# All other iconphoto tests are platform specific
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 893dfd7..490a1ea 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -2444,6 +2444,10 @@ WmIconphotoCmd(
photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i]));
if (photo == NULL) {
ckfree((char *) iconPropertyData);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "failed to create an iconphoto with image \"%s\"",
+ Tcl_GetString(objv[i])));
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}
Tk_PhotoGetSize(photo, &width, &height);
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index ba10c63..e6a0a4b 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -4379,9 +4379,9 @@ WmIconphotoCmd(
if (!iconInfo.hbmColor) {
ckfree(lpIR);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "failed to create color bitmap for \"%s\"",
+ "failed to create an iconphoto with image \"%s\"",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "BITMAP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WM", "ICONPHOTO", "IMAGE", NULL);
return TCL_ERROR;
}