summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-04-13 07:23:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-04-13 07:23:37 (GMT)
commit49879791f48b7a18d94b3f8ea1281e9eed7b0e37 (patch)
tree03609cb9e018c6c02c2a7f25470d34ddec08f723
parent8262e514d0b65f088e0799e9cea671f7efd1fa25 (diff)
downloadtcl-49879791f48b7a18d94b3f8ea1281e9eed7b0e37.zip
tcl-49879791f48b7a18d94b3f8ea1281e9eed7b0e37.tar.gz
tcl-49879791f48b7a18d94b3f8ea1281e9eed7b0e37.tar.bz2
Duplicate the private variable config when cloning objects.
-rw-r--r--generic/tclOO.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c
index db9f399..1080967 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -1904,6 +1904,7 @@ Tcl_CopyObjectInstance(
Class *mixinPtr;
CallContext *contextPtr;
Tcl_Obj *keyPtr, *filterObj, *variableObj, *args[3];
+ PrivateVariableMapping *privateVariable;
int i, result;
/*
@@ -1973,7 +1974,7 @@ Tcl_CopyObjectInstance(
}
/*
- * Copy the object's variable resolution list to the new object.
+ * Copy the object's variable resolution lists to the new object.
*/
DUPLICATE(o2Ptr->variables, oPtr->variables, Tcl_Obj *);
@@ -1981,6 +1982,13 @@ Tcl_CopyObjectInstance(
Tcl_IncrRefCount(variableObj);
}
+ DUPLICATE(o2Ptr->privateVariables, oPtr->privateVariables,
+ PrivateVariableMapping);
+ FOREACH_STRUCT(privateVariable, o2Ptr->privateVariables) {
+ Tcl_IncrRefCount(privateVariable->variableObj);
+ Tcl_IncrRefCount(privateVariable->fullNameObj);
+ }
+
/*
* Copy the object's flags to the new object, clearing those that must be
* kept object-local. The duplicate is never deleted at this point, nor is
@@ -2069,7 +2077,7 @@ Tcl_CopyObjectInstance(
}
/*
- * Copy the source class's variable resolution list.
+ * Copy the source class's variable resolution lists.
*/
DUPLICATE(cls2Ptr->variables, clsPtr->variables, Tcl_Obj *);
@@ -2077,6 +2085,13 @@ Tcl_CopyObjectInstance(
Tcl_IncrRefCount(variableObj);
}
+ DUPLICATE(cls2Ptr->privateVariables, clsPtr->privateVariables,
+ PrivateVariableMapping);
+ FOREACH_STRUCT(privateVariable, cls2Ptr->privateVariables) {
+ Tcl_IncrRefCount(privateVariable->variableObj);
+ Tcl_IncrRefCount(privateVariable->fullNameObj);
+ }
+
/*
* Duplicate the source class's mixins (which cannot be circular
* references to the duplicate).