summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-09-21 09:36:35 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-09-21 09:36:35 (GMT)
commitae2f2b211d31070531913851b894e2665b544beb (patch)
treef85bb98792c720e90346badc16cb7db5dd867027 /generic/tclVar.c
parent65d17884a3fc402968d737201112e8006e371434 (diff)
parent3b786ffebeb7769d34099ea7064532501dc6aee5 (diff)
downloadtcl-winFixes.zip
tcl-winFixes.tar.gz
tcl-winFixes.tar.bz2
merge core-8-6-branch. Undo changes to coffbase.txt (they cause overlap with Tk)winFixes
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 2adffbc..46a1da6 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -5193,13 +5193,16 @@ TclDeleteNamespaceVars(
VarHashRefCount(varPtr)++; /* Make sure we get to remove from
* hash. */
Tcl_GetVariableFullName(interp, (Tcl_Var) varPtr, objPtr);
- UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr, NULL, flags,
- -1);
- Tcl_DecrRefCount(objPtr); /* Free no longer needed obj */
+ UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
+ NULL, flags, -1);
/*
- * Remove the variable from the table and force it undefined in case
- * an unset trace brought it back from the dead.
+ * We just unset the variable. However, an unset trace might
+ * have re-set it, or might have re-established traces on it.
+ * This namespace and its vartable are going away unconditionally,
+ * so we cannot let such things linger. That would be a leak.
+ *
+ * First we destroy all traces. ...
*/
if (TclIsVarTraced(varPtr)) {
@@ -5223,6 +5226,17 @@ TclDeleteNamespaceVars(
}
}
}
+
+ /*
+ * ...and then, if the variable still holds a value, we unset it
+ * again. This time with no traces left, we're sure it goes away.
+ */
+
+ if (!TclIsVarUndefined(varPtr)) {
+ UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
+ NULL, flags, -1);
+ }
+ Tcl_DecrRefCount(objPtr); /* free no longer needed obj */
VarHashRefCount(varPtr)--;
VarHashDeleteEntry(varPtr);
}