diff options
author | dgp <dgp@noemail.net> | 2006-03-20 22:58:45 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2006-03-20 22:58:45 (GMT) |
commit | f4b6380066cc1dc3c7bf966ab60ffe9eb15e97e6 (patch) | |
tree | d33b1392b173e0f11d1e79559391731c3eadbd8a /generic/tkConsole.c | |
parent | 6f16885c09ba9dfc1292c36ff89eff5655d15fc0 (diff) | |
download | tk-f4b6380066cc1dc3c7bf966ab60ffe9eb15e97e6.zip tk-f4b6380066cc1dc3c7bf966ab60ffe9eb15e97e6.tar.gz tk-f4b6380066cc1dc3c7bf966ab60ffe9eb15e97e6.tar.bz2 |
* generic/tkConsole.c: Added exit handler to clean up the interp
where the console window lives.
FossilOrigin-Name: 46b926ebcb8ebcf5ddd0a794f4e1ae2d2bca631d
Diffstat (limited to 'generic/tkConsole.c')
-rw-r--r-- | generic/tkConsole.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/generic/tkConsole.c b/generic/tkConsole.c index b3bd182..f43ad31 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkConsole.c,v 1.27 2006/03/16 22:51:15 dgp Exp $ + * RCS: @(#) $Id: tkConsole.c,v 1.28 2006/03/20 22:58:46 dgp Exp $ */ #include "tk.h" @@ -57,6 +57,7 @@ static int ConsoleObjCmd(ClientData clientData, Tcl_Interp *interp, static int ConsoleOutput(ClientData instanceData, CONST char *buf, int toWrite, int *errorCode); static void ConsoleWatch(ClientData instanceData, int mask); +static void DeleteConsoleInterp(ClientData clientData); static void InterpDeleteProc(ClientData clientData, Tcl_Interp *interp); static int InterpreterObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); @@ -200,8 +201,8 @@ ShouldUseConsoleChannel( * Tk_InitConsoleChannels -- * * Create the console channels and install them as the standard channels. - * All I/O will be discarded until TkConsoleInit is called to attach the - * console to a text widget. + * All I/O will be discarded until Tk_CreateConsoleWindow is called to + * attach the console to a text widget. * * Results: * None. @@ -387,10 +388,10 @@ Tk_CreateConsoleWindow( info->consoleInterp = consoleInterp; info->interp = interp; - /* TODO: establish exit handler for cleanup */ - Tcl_CallWhenDeleted(consoleInterp, InterpDeleteProc, (ClientData) info); info->refCount++; + Tcl_CreateThreadExitHandler(DeleteConsoleInterp, + (ClientData) consoleInterp); /* * Add console commands to the interp @@ -781,6 +782,25 @@ InterpreterObjCmd( /* *---------------------------------------------------------------------- * + * DeleteConsoleInterp -- + * + * Thread exit handler to destroy a console interp when the + * thread it lives in gets torn down. + * + *---------------------------------------------------------------------- + */ + +static void +DeleteConsoleInterp( + ClientData clientData) +{ + Tcl_Interp *interp = (Tcl_Interp *)clientData; + Tcl_DeleteInterp(interp); +} + +/* + *---------------------------------------------------------------------- + * * InterpDeleteProc -- * * React when the interp in which the console is displayed is deleted @@ -803,6 +823,8 @@ InterpDeleteProc( ConsoleInfo *info = (ConsoleInfo *) clientData; if (info->consoleInterp == interp) { + Tcl_DeleteThreadExitHandler(DeleteConsoleInterp, + (ClientData) info->consoleInterp); info->consoleInterp = NULL; } if (--info->refCount <= 0) { |