summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-07-26 16:21:30 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-07-26 16:21:30 (GMT)
commitf0db0d96ba29b85631aa547feecc430a3b0ec221 (patch)
tree6a7f5088733fb6d6609d7f6053d0744fdeb2044c
parent55b00b8f71a73c471cbc1e1c6cc99fa5b39f019d (diff)
downloadtcl-f0db0d96ba29b85631aa547feecc430a3b0ec221.zip
tcl-f0db0d96ba29b85631aa547feecc430a3b0ec221.tar.gz
tcl-f0db0d96ba29b85631aa547feecc430a3b0ec221.tar.bz2
* 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]
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclNamesp.c36
-rw-r--r--tests/trace.test13
3 files changed, 36 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index e029a4e..a068a83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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/configure: Regen.
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 9230cf0..3367af9 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -21,7 +21,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.80 2005/07/17 21:17:43 dkf Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.81 2005/07/26 16:21:31 dgp Exp $
*/
#include "tclInt.h"
@@ -1055,6 +1055,23 @@ TclTeardownNamespace(nsPtr)
Tcl_InitHashTable(&nsPtr->varTable, TCL_STRING_KEYS);
/*
+ * 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.
+ *
+ * Don't optimize to Tcl_NextHashEntry() because of traces.
+ */
+
+ 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.
*/
@@ -1102,23 +1119,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.
- *
- * Don't optimize to Tcl_NextHashEntry() because of traces.
- */
-
- 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 d4a777f..b158c3a 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.38 2005/06/21 18:33:05 dgp Exp $
+# RCS: @(#) $Id: trace.test,v 1.39 2005/07/26 16:21:31 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -2237,6 +2237,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}
+
test trace-35.1 {527164: Keep -errorinfo of traces} -setup {
unset -nocomplain x y
} -body {