summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-03-20 22:58:45 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-03-20 22:58:45 (GMT)
commit1ed4bd550b5b14493cf7673adfc2657f1e70bbfd (patch)
treed33b1392b173e0f11d1e79559391731c3eadbd8a
parentd7912924837f005844a540aaf3c39c5e59556885 (diff)
downloadtk-1ed4bd550b5b14493cf7673adfc2657f1e70bbfd.zip
tk-1ed4bd550b5b14493cf7673adfc2657f1e70bbfd.tar.gz
tk-1ed4bd550b5b14493cf7673adfc2657f1e70bbfd.tar.bz2
* generic/tkConsole.c: Added exit handler to clean up the interp
where the console window lives.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkConsole.c32
2 files changed, 32 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index b20829a..04bd1b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-20 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tkConsole.c: Added exit handler to clean up the interp
+ where the console window lives.
+
2006-03-18 Vince Darley <vincentdarley@users.sourceforge.net>
* generic/tkText.c: fix for undo/modified status of text
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) {