summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2018-11-07 23:59:23 (GMT)
committerculler <culler>2018-11-07 23:59:23 (GMT)
commitba13f6682c067d785a209b8217c62dabe4884d02 (patch)
treedf8552e6a1426bcea0e75650b2e86ba13fecf0b7 /macosx
parent6a78e0b7fc7c69f35442f490812e5265db8e8470 (diff)
downloadtk-ba13f6682c067d785a209b8217c62dabe4884d02.zip
tk-ba13f6682c067d785a209b8217c62dabe4884d02.tar.gz
tk-ba13f6682c067d785a209b8217c62dabe4884d02.tar.bz2
Fix crash due to key events from the about dialog having an NSWindow with no Tk window.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXKeyEvent.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index f79185e..e717a20 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -68,15 +68,19 @@ unsigned short releaseCode;
processingCompose = NO;
}
+ w = [theEvent window];
+ TkWindow *winPtr = TkMacOSXGetTkWindow(w);
+ Tk_Window tkwin = (Tk_Window) winPtr;
+ XEvent xEvent;
+
+ if (!winPtr) {
+ return theEvent;
+ }
+
switch (type) {
case NSKeyUp:
-
/*Fix for bug #1ba71a86bb: key release firing on key press.*/
- w = [theEvent window];
- XEvent xEvent;
setupXEvent(&xEvent, w, 0);
- TkWindow *winPtr = TkMacOSXGetTkWindow(w);
- Tk_Window tkwin = (Tk_Window) winPtr;
xEvent.xany.type = KeyRelease;
xEvent.xkey.keycode = releaseCode;
xEvent.xany.serial = LastKnownRequestProcessed(Tk_Display(tkwin));
@@ -89,7 +93,7 @@ unsigned short releaseCode;
modifiers = [theEvent modifierFlags];
keyCode = [theEvent keyCode];
// w = [self windowWithWindowNumber:[theEvent windowNumber]];
- w = [theEvent window];
+ // w = [theEvent window];
#if defined(TK_MAC_DEBUG_EVENTS) || NS_KEYLOG == 1
TKLog(@"-[%@(%p) %s] r=%d mods=%u '%@' '%@' code=%u c=%d %@ %d", [self class], self, _cmd, repeat, modifiers, characters, charactersIgnoringModifiers, keyCode,([charactersIgnoringModifiers length] == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0], w, type);
#endif