From 770d3ab7c71b257d3aee36fbd5346a71be5df6dd Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 11 Nov 2019 01:45:54 +0000 Subject: Allow creating 0x0 NSImages, which work e.g. in labels, just don't allow using them as iconphoto images. --- macosx/tkMacOSXDraw.c | 2 +- macosx/tkMacOSXWm.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 3f7ca0a..fb6a8a0 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -504,7 +504,7 @@ TkMacOSXGetNSImageWithTkImage( Pixmap pixmap; NSImage *nsImage; if (width == 0 | height == 0) { - return NULL; + 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); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 086746b..0d49d74 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,10 +2564,11 @@ 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( -- cgit v0.12