summaryrefslogtreecommitdiffstats
path: root/generic/tclOOMethod.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2011-03-05 16:31:26 (GMT)
committerKevin B Kenny <kennykb@acm.org>2011-03-05 16:31:26 (GMT)
commite5eafc26411072617eb6671161e84ddfbbf99bba (patch)
tree63741735edd48be8ee7aa9bfe8b32092b1d94fb8 /generic/tclOOMethod.c
parent7e907ec87a885ad9d187dbc73741df94519b73ed (diff)
parentbc47f3260fa46a560c1a2e7e1a0891e5493cda50 (diff)
downloadtcl-e5eafc26411072617eb6671161e84ddfbbf99bba.zip
tcl-e5eafc26411072617eb6671161e84ddfbbf99bba.tar.gz
tcl-e5eafc26411072617eb6671161e84ddfbbf99bba.tar.bz2
Diffstat (limited to 'generic/tclOOMethod.c')
-rw-r--r--generic/tclOOMethod.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c
index bb10ca5..4f29337 100644
--- a/generic/tclOOMethod.c
+++ b/generic/tclOOMethod.c
@@ -7,8 +7,6 @@
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tclOOMethod.c,v 1.31 2011/01/18 15:44:41 dkf Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -1057,6 +1055,14 @@ ProcedureMethodCompiledVarConnect(
}
if (cacheIt) {
infoPtr->cachedObjectVar = TclVarHashGetValue(hPtr);
+
+ /*
+ * We must keep a reference to the variable so everything will
+ * continue to work correctly even if it is unset; being unset does
+ * not end the life of the variable at this level. [Bug 3185009]
+ */
+
+ VarHashRefCount(infoPtr->cachedObjectVar)++;
}
return TclVarHashGetValue(hPtr);
}
@@ -1067,6 +1073,14 @@ ProcedureMethodCompiledVarDelete(
{
OOResVarInfo *infoPtr = (OOResVarInfo *) rPtr;
+ /*
+ * Release the reference to the variable if we were holding it.
+ */
+
+ if (infoPtr->cachedObjectVar) {
+ VarHashRefCount(infoPtr->cachedObjectVar)--;
+ TclCleanupVar((Var *) infoPtr->cachedObjectVar, NULL);
+ }
Tcl_DecrRefCount(infoPtr->variableObj);
ckfree((char *) infoPtr);
}