summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclBasic.c27
-rw-r--r--tests/io.test11
2 files changed, 22 insertions, 16 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 660aa67..7337885 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -3468,6 +3468,19 @@ Tcl_DeleteCommandFromToken(
iPtr->compileEpoch++;
}
+ if (!(cmdPtr->flags & CMD_REDEF_IN_PROGRESS)) {
+ /*
+ * Delete any imports of this routine before deleting this routine itself.
+ * See issue 688fcc7082fa.
+ */
+ for (refPtr = cmdPtr->importRefPtr; refPtr != NULL;
+ refPtr = nextRefPtr) {
+ nextRefPtr = refPtr->nextPtr;
+ importCmd = (Tcl_Command) refPtr->importedCmdPtr;
+ Tcl_DeleteCommandFromToken(interp, importCmd);
+ }
+ }
+
if (cmdPtr->deleteProc != NULL) {
/*
* Delete the command's client data. If this was an imported command
@@ -3488,20 +3501,6 @@ Tcl_DeleteCommandFromToken(
}
/*
- * If this command was imported into other namespaces, then imported
- * commands were created that refer back to this command. Delete these
- * imported commands now.
- */
- if (!(cmdPtr->flags & CMD_REDEF_IN_PROGRESS)) {
- for (refPtr = cmdPtr->importRefPtr; refPtr != NULL;
- refPtr = nextRefPtr) {
- nextRefPtr = refPtr->nextPtr;
- importCmd = (Tcl_Command) refPtr->importedCmdPtr;
- Tcl_DeleteCommandFromToken(interp, importCmd);
- }
- }
-
- /*
* Don't use hPtr to delete the hash entry here, because it's possible
* that the deletion callback renamed the command. Instead, use
* cmdPtr->hptr, and make sure that no-one else has already deleted the
diff --git a/tests/io.test b/tests/io.test
index c78492b..ca37870 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -6935,7 +6935,7 @@ test io-50.5 {testing handler deletion vs reentrant calls} -constraints {testcha
} -cleanup {
close $f
} -result [list {del calling recursive} {del deleted notcalled} \
- {del deleted myself} {del after recursive}]
+ {del deleted myself} {del after recursive}]
test io-50.6 {testing handler deletion vs reentrant calls} -constraints {testchannelevent testservicemode} -setup {
file delete $path(test1)
} -body {
@@ -6944,6 +6944,7 @@ test io-50.6 {testing handler deletion vs reentrant calls} -constraints {testcha
proc first {f} {
variable u
variable z
+ variable done
if {"$u" == "toplevel"} {
lappend z "first called"
set u first
@@ -6951,6 +6952,7 @@ test io-50.6 {testing handler deletion vs reentrant calls} -constraints {testcha
vwait z
after cancel $timer
lappend z "first after toplevel"
+ set done 1
} else {
lappend z "first called not toplevel"
}
@@ -6972,19 +6974,24 @@ test io-50.6 {testing handler deletion vs reentrant calls} -constraints {testcha
}
set z ""
set u toplevel
+ set done 0
testservicemode 0
set f [open $path(test1) r]
testchannelevent $f add readable [namespace code [list second $f]]
testchannelevent $f add readable [namespace code [list first $f]]
testservicemode 1
update
+ if {!$done} {
+ set timer2 [after 200 set done 1]
+ vwait done
+ after cancel $timer2
+ }
set z
} -cleanup {
close $f
} -result [list {first called} {first called not toplevel} \
{second called, first time} {second called, second time} \
{first after toplevel}]
-
test io-51.1 {Test old socket deletion on Macintosh} {socket} {
set x 0
set result ""