Tk Source Code

Artifact [de324106]
Login

Artifact de3241065ec182060fca450a4838f80b5d9dc6e05a42b63cb042d0fd0ba7751b:

Attachment "keywindow2.patch" to ticket [d4d89d13] added by marc_culler 2026-03-22 13:02:51.
Index: macosx/tkMacOSXWm.c
==================================================================
--- macosx/tkMacOSXWm.c
+++ macosx/tkMacOSXWm.c
@@ -842,10 +842,13 @@
 void TkMacOSXAssignNewKeyWindow(
     Tcl_Interp *interp,
     NSWindow *ignore)
 {
     TkWindow *winPtr;
+    if ([NSApp tkWillExit]) {
+	return;
+    }
 
     /*
      * Avoid bug 5692042764: set tkEventTarget to NULL if there is no window to
      * send Tk events to.
      */
@@ -1321,11 +1324,11 @@
 	    [NSApp _setKeyWindow:nil];
 	    [NSApp _setMainWindow:nil];
 	}
 
 	/*
-	 * Find a new keyWindow.  It will be assinged as the new
+	 * Find a new keyWindow.  It will be assigned as the new
 	 * TkEventTarget when [NSApp WindowActivation] is called..
 	 */
 
 	TkMacOSXAssignNewKeyWindow(Tk_Interp((Tk_Window) winPtr), deadNSWindow);