diff options
author | culler <culler> | 2019-11-17 17:11:32 (GMT) |
---|---|---|
committer | culler <culler> | 2019-11-17 17:11:32 (GMT) |
commit | 48180e5c2ae6d5ad17cbf9eeb98b971c4e1b7a0f (patch) | |
tree | 5be3fdd6b4f2bdc8f71af49c7ff1a61dfc043f9c /macosx | |
parent | 5fa1f5ca17abac3ec8d2d646fbf138502a0f4a59 (diff) | |
parent | 5bc76fef182c52a50e34b7f95c43f194ea8711fe (diff) | |
download | tk-48180e5c2ae6d5ad17cbf9eeb98b971c4e1b7a0f.zip tk-48180e5c2ae6d5ad17cbf9eeb98b971c4e1b7a0f.tar.gz tk-48180e5c2ae6d5ad17cbf9eeb98b971c4e1b7a0f.tar.bz2 |
Fix [53d28027e3]: macOS crashes with 0x0 image for wm iconphoto; make wm iconphoto behavior consistent between platforms.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXDraw.c | 7 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 11 |
2 files changed, 13 insertions, 5 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]; |