summaryrefslogtreecommitdiffstats
path: root/generic/tkConsole.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkConsole.c')
-rw-r--r--generic/tkConsole.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index cfb9219..5233749 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.18.2.1 2005/06/03 15:25:01 dkf Exp $
+ * RCS: @(#) $Id: tkConsole.c,v 1.18.2.2 2005/06/23 22:07:13 das Exp $
*/
#include "tk.h"
@@ -36,7 +36,7 @@ typedef struct ConsoleInfo {
* command and that is fragile. [Bug 1016385]
*/
-#define TK_CONSOLE_INFO_KEY "tk::ConsoleInfo"
+#define TK_CONSOLE_INFO_KEY "tk::ConsoleInfo"
typedef struct ThreadSpecificData {
Tcl_Interp *gStdoutInterp;
@@ -346,7 +346,7 @@ Tk_CreateConsoleWindow(interp)
#else
static const char *initCmd = "source $tk_library/console.tcl";
#endif
-
+
consoleInterp = Tcl_CreateInterp();
if (consoleInterp == NULL) {
goto error;
@@ -601,9 +601,9 @@ ConsoleCmd(clientData, interp, argc, argv)
Tcl_Eval(consoleInterp, Tcl_DStringValue(&dString));
Tcl_DStringFree(&dString);
} else if ((c == 'h') && (strncmp(argv[1], "hide", length)) == 0) {
- Tcl_Eval(consoleInterp, "wm withdraw . ");
+ Tcl_Eval(consoleInterp, "wm withdraw .");
} else if ((c == 's') && (strncmp(argv[1], "show", length)) == 0) {
- Tcl_Eval(consoleInterp, "wm deiconify . ");
+ Tcl_Eval(consoleInterp, "wm deiconify .");
} else if ((c == 'e') && (strncmp(argv[1], "eval", length)) == 0) {
if (argc == 3) {
result = Tcl_Eval(consoleInterp, argv[2]);
@@ -652,6 +652,7 @@ InterpreterCmd(clientData, interp, argc, argv)
char c;
size_t length;
int result;
+ Tcl_Interp *consoleInterp;
Tcl_Interp *otherInterp;
if (argc < 2) {
@@ -662,6 +663,8 @@ InterpreterCmd(clientData, interp, argc, argv)
c = argv[1][0];
length = strlen(argv[1]);
+ consoleInterp = info->consoleInterp;
+ Tcl_Preserve((ClientData) consoleInterp);
otherInterp = info->interp;
Tcl_Preserve((ClientData) otherInterp);
if ((c == 'e') && (strncmp(argv[1], "eval", length)) == 0) {
@@ -679,6 +682,7 @@ InterpreterCmd(clientData, interp, argc, argv)
result = TCL_ERROR;
}
Tcl_Release((ClientData) otherInterp);
+ Tcl_Release((ClientData) consoleInterp);
return result;
}
@@ -704,6 +708,17 @@ ConsoleDeleteProc(clientData)
ClientData clientData;
{
ConsoleInfo *info = (ConsoleInfo *) clientData;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ /*
+ * Also need to null this out to prevent any further use.
+ *
+ * Fix [Bug #756840]
+ */
+ if (tsdPtr != NULL) {
+ tsdPtr->gStdoutInterp = NULL;
+ }
Tcl_DeleteInterp(info->consoleInterp);
info->consoleInterp = NULL;
@@ -737,7 +752,8 @@ ConsoleEventProc(clientData, eventPtr)
Tcl_Interp *consoleInterp;
if (eventPtr->type == DestroyNotify) {
- consoleInterp = info->consoleInterp;
+
+ consoleInterp = info->consoleInterp;
/*
* It is possible that the console interpreter itself has
@@ -746,7 +762,9 @@ ConsoleEventProc(clientData, eventPtr)
* gone, we do not have to do any work here.
*/
- if (consoleInterp != (Tcl_Interp *) NULL) {
+ if (consoleInterp == (Tcl_Interp *) NULL) {
+ return;
+ } else {
Tcl_Preserve((ClientData) consoleInterp);
Tcl_Eval(consoleInterp, "::tk::ConsoleExit");
Tcl_Release((ClientData) consoleInterp);
@@ -789,7 +807,7 @@ TkConsolePrint(interp, devId, buffer, size)
}
info = (ConsoleInfo *) Tcl_GetAssocData(interp, TK_CONSOLE_INFO_KEY, NULL);
- if (info->consoleInterp == NULL) {
+ if (info == NULL || info->consoleInterp == NULL) {
return;
}