From a035d9f0c9008fbb62a43d011474036c0c56ed3c Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 21 Mar 2006 03:01:26 +0000 Subject: * generic/tkConsole.c: Added exit handler to clean up the interp where the console window lives. Also added code to handle multiple calls to Tk_CreateConsoleWindow so that the console channels connect to the last console window opened, in compatibility with the previous implementation. --- ChangeLog | 5 ++++- generic/tkConsole.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04bd1b8..7bb4991 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,10 @@ 2006-03-20 Don Porter * generic/tkConsole.c: Added exit handler to clean up the interp - where the console window lives. + where the console window lives. Also added code to handle + multiple calls to Tk_CreateConsoleWindow so that the console + channels connect to the last console window opened, in compatibility + with the previous implementation. 2006-03-18 Vince Darley diff --git a/generic/tkConsole.c b/generic/tkConsole.c index f43ad31..e9b406c 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.28 2006/03/20 22:58:46 dgp Exp $ + * RCS: @(#) $Id: tkConsole.c,v 1.29 2006/03/21 03:01:27 dgp Exp $ */ #include "tk.h" @@ -372,13 +372,32 @@ Tk_CreateConsoleWindow( ChannelData *data = (ChannelData *)Tcl_GetChannelInstanceData(chan); info = data->info; if (info->consoleInterp) { - /* - * TODO: The console channels are already connected to a console - * window. Move channels to this new one, but leave the old one - * functioning. - */ - - + /* New ConsoleInfo for a new console window */ + info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); + info->refCount = 0; + + /* Update any console channels to make use of the new console */ + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDIN)) + == &consoleChannelType) { + data = (ChannelData *)Tcl_GetChannelInstanceData(chan); + data->info->refCount--; + data->info = info; + data->info->refCount++; + } + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDOUT)) + == &consoleChannelType) { + data = (ChannelData *)Tcl_GetChannelInstanceData(chan); + data->info->refCount--; + data->info = info; + data->info->refCount++; + } + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDERR)) + == &consoleChannelType) { + data = (ChannelData *)Tcl_GetChannelInstanceData(chan); + data->info->refCount--; + data->info = info; + data->info->refCount++; + } } } else { info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); -- cgit v0.12