diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tclNamesp.c | 32 | ||||
-rw-r--r-- | tests/trace.test | 13 |
3 files changed, 34 insertions, 17 deletions
@@ -1,3 +1,9 @@ +2005-07-26 Don Porter <dgp@users.sourceforge.net> + + * generic/tclNamesp.c (TclTeardownNamespace): Re-ordering so that + * tests/trace.test (trace-34.4): command delete traces fire + while the command still exists. [Bug 1047286] + 2005-07-24 Mo DeJong <mdejong@users.sourceforge.net> * unix/tcl.m4 (SC_PROG_TCLSH, SC_BUILD_TCLSH): diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 3eb1bb2..1f72076 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -19,7 +19,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclNamesp.c,v 1.31.2.7 2005/07/05 17:27:08 dgp Exp $ + * RCS: @(#) $Id: tclNamesp.c,v 1.31.2.8 2005/07/26 16:20:44 dgp Exp $ */ #include "tclInt.h" @@ -737,6 +737,21 @@ TclTeardownNamespace(nsPtr) } /* + * Delete all commands in this namespace. Be careful when traversing the + * hash table: when each command is deleted, it removes itself from the + * command table. + */ + + for (entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search); + entryPtr != NULL; + entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search)) { + cmd = (Tcl_Command) Tcl_GetHashValue(entryPtr); + Tcl_DeleteCommandFromToken((Tcl_Interp *) iPtr, cmd); + } + Tcl_DeleteHashTable(&nsPtr->cmdTable); + Tcl_InitHashTable(&nsPtr->cmdTable, TCL_STRING_KEYS); + + /* * Remove the namespace from its parent's child hashtable. */ @@ -766,21 +781,6 @@ TclTeardownNamespace(nsPtr) } /* - * Delete all commands in this namespace. Be careful when traversing the - * hash table: when each command is deleted, it removes itself from the - * command table. - */ - - for (entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search); - entryPtr != NULL; - entryPtr = Tcl_FirstHashEntry(&nsPtr->cmdTable, &search)) { - cmd = (Tcl_Command) Tcl_GetHashValue(entryPtr); - Tcl_DeleteCommandFromToken((Tcl_Interp *) iPtr, cmd); - } - Tcl_DeleteHashTable(&nsPtr->cmdTable); - Tcl_InitHashTable(&nsPtr->cmdTable, TCL_STRING_KEYS); - - /* * Free the namespace's export pattern array. */ diff --git a/tests/trace.test b/tests/trace.test index e0c6648..7df886f 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: trace.test,v 1.26.2.6 2005/06/21 17:19:43 dgp Exp $ +# RCS: @(#) $Id: trace.test,v 1.26.2.7 2005/07/26 16:20:46 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -2172,6 +2172,17 @@ test trace-34.3 {Bug 1224585} { foo } {} +test trace-34.4 {Bug 1047286} { + variable x notrace + proc callback {old - -} { + variable x "$old exists" [namespace which -command $old]" + } + namespace eval ::foo {proc bar {} {}} + trace add command ::foo::bar delete [namespace code callback] + namespace delete ::foo + set x +} {::foo::bar exists: ::foo::bar} + # Delete procedures when done, so we don't clash with other tests # (e.g. foobar will clash with 'unknown' tests). catch {rename foobar {}} |