summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkevin_walzer <kevin_walzer@noemail.net>2015-03-21 01:30:55 (GMT)
committerkevin_walzer <kevin_walzer@noemail.net>2015-03-21 01:30:55 (GMT)
commitea74203ee2744efcb94243368645428d3bb50e1a (patch)
tree62b0a4ce92f230413e71f7eedeef62e116873298
parent86e3be61051bf93c9ae90857f5707c2336854087 (diff)
downloadtk-ea74203ee2744efcb94243368645428d3bb50e1a.zip
tk-ea74203ee2744efcb94243368645428d3bb50e1a.tar.gz
tk-ea74203ee2744efcb94243368645428d3bb50e1a.tar.bz2
Improvement of memory management, removal of zombie windows from Tk-Cocoa; thanks to Marc Culler for patch
FossilOrigin-Name: e3b0c37c45483a62a51d2c2a0818cacd9ca19d56
-rw-r--r--macosx/tkMacOSXKeyEvent.c17
-rw-r--r--macosx/tkMacOSXMenu.c2
2 files changed, 13 insertions, 6 deletions
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index 09cdf94..7e7e8e4 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -27,7 +27,9 @@ static Tk_Window grabWinPtr = NULL;
/* Current grab window, NULL if no grab. */
static Tk_Window keyboardGrabWinPtr = NULL;
/* Current keyboard grab window. */
-static NSModalSession modalSession = NULL;
+static NSWindow *keyboardGrabNSWindow = nil;
+ /* NSWindow for the current keyboard grab window. */
+static NSModalSession modalSession = nil;
static BOOL processingCompose = NO;
static BOOL finishedCompose = NO;
@@ -476,7 +478,9 @@ XGrabKeyboard(
if (modalSession) {
Tcl_Panic("XGrabKeyboard: already grabbed");
}
- modalSession = [NSApp beginModalSessionForWindow:[w retain]];
+ keyboardGrabNSWindow = w;
+ [w retain];
+ modalSession = [NSApp beginModalSessionForWindow:w];
}
}
return GrabSuccess;
@@ -504,11 +508,12 @@ XUngrabKeyboard(
Time time)
{
if (modalSession) {
- NSWindow *w = keyboardGrabWinPtr ? TkMacOSXDrawableWindow(
- ((TkWindow *) keyboardGrabWinPtr)->window) : nil;
[NSApp endModalSession:modalSession];
- [w release];
- modalSession = NULL;
+ modalSession = nil;
+ }
+ if (keyboardGrabNSWindow) {
+ [keyboardGrabNSWindow release];
+ keyboardGrabNSWindow = nil;
}
keyboardGrabWinPtr = NULL;
}
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 0cc874c..ed22640 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -261,6 +261,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
/*Add time for errors to fire if necessary. This is sub-optimal but avoids issues with Tcl/Cocoa event loop integration.*/
Tcl_Sleep(100);
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
Tcl_Preserve(interp);
Tcl_Preserve(menuPtr);
@@ -273,6 +274,7 @@ static int ModifierCharWidth(Tk_Font tkfont);
}
Tcl_Release(menuPtr);
Tcl_Release(interp);
+ [pool drain];
}
}
}