diff options
author | culler <culler> | 2018-11-11 06:48:07 (GMT) |
---|---|---|
committer | culler <culler> | 2018-11-11 06:48:07 (GMT) |
commit | d1d67157b8f5db89f44ecb28e4a06cb6380ae530 (patch) | |
tree | 8276ac6cc3f739c814ff1cc1e4af3715ae4deee8 /macosx | |
parent | a9b367c36191b1de125ece91b539a0160b5cc93f (diff) | |
download | tk-d1d67157b8f5db89f44ecb28e4a06cb6380ae530.zip tk-d1d67157b8f5db89f44ecb28e4a06cb6380ae530.tar.gz tk-d1d67157b8f5db89f44ecb28e4a06cb6380ae530.tar.bz2 |
Always check whether the return value of TkMacOSXGetTkWindow is NULL.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXImage.c | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 3 | ||||
-rw-r--r-- | macosx/tkMacOSXMenus.c | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 12 |
5 files changed, 25 insertions, 16 deletions
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 22882d2..a5c870a 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -540,12 +540,12 @@ TkPutImage( if (dc.context) { CGRect bounds, srcRect, dstRect; CGImageRef img = TkMacOSXCreateCGImageWithXImage(image); - if (macDraw->flags & TK_IS_PIXMAP) { - /* - * The CGContext for a pixmap is RGB only, with A = 0. - */ - CGContextSetBlendMode(dc.context, kCGImageAlphaNoneSkipLast); - } else { + + /* + * The CGContext for a pixmap is RGB only, with A = 0. + */ + + if (!(macDraw->flags & TK_IS_PIXMAP)) { CGContextSetBlendMode(dc.context, kCGBlendModeSourceAtop); } if (img) { diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 46662e5..31fffa1 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -434,6 +434,9 @@ setupXEvent(XEvent *xEvent, NSWindow *w, unsigned int state) { TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; + if (!winPtr) { + return; + } memset(xEvent, 0, sizeof(XEvent)); xEvent->xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index f8f00a6..15dbad4 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -379,13 +379,13 @@ GenerateEditEvent( XVirtualEvent event; int x, y; TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]); - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin; - if (tkwin == NULL) { + if (!winPtr) { return; } tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; - if (tkwin == NULL) { + if (!tkwin) { return; } bzero(&event, sizeof(XVirtualEvent)); diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 442029d..a1a3d1a 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1008,14 +1008,9 @@ ConfigureRestrictProc( TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; - /* - * If there is no Tk window associated to this NSWindow, just return. - */ - if (!winPtr) { return; } - bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); @@ -1055,6 +1050,9 @@ ConfigureRestrictProc( int x, y; TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); Tk_Window tkwin = (Tk_Window) winPtr; + if (!winPtr){ + return; + } bzero(&event, sizeof(XVirtualEvent)); event.type = VirtualEvent; event.serial = LastKnownRequestProcessed(Tk_Display(tkwin)); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index ed930fe..33a88d8 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -403,6 +403,9 @@ NSStatusItem *exitFullScreen; - (void)toggleFullScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); + if (!winPtr) { + return; + } Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); if ([NSApp macMinorVersion] > 12) { if (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask) { @@ -418,6 +421,9 @@ NSStatusItem *exitFullScreen; -(void)restoreOldScreen:(id)sender { TkWindow *winPtr = TkMacOSXGetTkWindow(self); + if (!winPtr) { + return; + } Tcl_Interp *interp = Tk_Interp((Tk_Window)winPtr); TkMacOSXMakeFullscreen(winPtr, self, 0, interp); @@ -431,8 +437,10 @@ NSStatusItem *exitFullScreen; - (BOOL) canBecomeKeyWindow { TkWindow *winPtr = TkMacOSXGetTkWindow(self); - - return (winPtr && winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == + if (!winPtr) { + return NO; + } + return (winPtr->wmInfoPtr && (winPtr->wmInfoPtr->macClass == kHelpWindowClass || winPtr->wmInfoPtr->attributes & kWindowNoActivatesAttribute)) ? NO : YES; } |