diff options
author | dgp <dgp@users.sourceforge.net> | 2006-03-21 03:01:26 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2006-03-21 03:01:26 (GMT) |
commit | a035d9f0c9008fbb62a43d011474036c0c56ed3c (patch) | |
tree | bca5bb0681c64b92fb5ae76da7d8104a36d8b681 | |
parent | 1ed4bd550b5b14493cf7673adfc2657f1e70bbfd (diff) | |
download | tk-a035d9f0c9008fbb62a43d011474036c0c56ed3c.zip tk-a035d9f0c9008fbb62a43d011474036c0c56ed3c.tar.gz tk-a035d9f0c9008fbb62a43d011474036c0c56ed3c.tar.bz2 |
* 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.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tkConsole.c | 35 |
2 files changed, 31 insertions, 9 deletions
@@ -1,7 +1,10 @@ 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. + 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 <vincentdarley@users.sourceforge.net> 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)); |