summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-08-14 10:53:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-08-14 10:53:39 (GMT)
commit68419d2d6bedf1ae539fbdd80c50eff66b90e883 (patch)
treec94eb9ac635555edd735af8a8e6f8f7fddb363fe
parent659e373aa07b9b9edde1a077fdde98b1c7cc5816 (diff)
downloadtk-68419d2d6bedf1ae539fbdd80c50eff66b90e883.zip
tk-68419d2d6bedf1ae539fbdd80c50eff66b90e883.tar.gz
tk-68419d2d6bedf1ae539fbdd80c50eff66b90e883.tar.bz2
Fix reference counting for "option" objects, when being duplicated.bug_069c9e43c4
-rw-r--r--generic/tkConfig.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index cfa5003..82b2e01 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -129,6 +129,7 @@ static Option * GetOptionFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, OptionTable *tablePtr);
static int ObjectIsEmpty(Tcl_Obj *objPtr);
static void FreeOptionInternalRep(Tcl_Obj *objPtr);
+static void DupOptionInternalRep(Tcl_Obj *, Tcl_Obj *);
/*
* The structure below defines an object type that is used to cache the result
@@ -140,7 +141,7 @@ static void FreeOptionInternalRep(Tcl_Obj *objPtr);
static const Tcl_ObjType optionObjType = {
"option", /* name */
FreeOptionInternalRep, /* freeIntRepProc */
- NULL, /* dupIntRepProc */
+ DupOptionInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
NULL /* setFromAnyProc */
};
@@ -1172,6 +1173,28 @@ FreeOptionInternalRep(
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
}
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * DupOptionInternalRep --
+ *
+ * When a cached style object is duplicated, this is called to update the
+ * internal reps.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static void
+DupOptionInternalRep(
+ Tcl_Obj *srcObjPtr, /* The object we are copying from. */
+ Tcl_Obj *dupObjPtr) /* The object we are copying to. */
+{
+ register OptionTable *tablePtr = (OptionTable *) srcObjPtr->internalRep.twoPtrValue.ptr1;
+ tablePtr->refCount++;
+ dupObjPtr->typePtr = srcObjPtr->typePtr;
+ dupObjPtr->internalRep = srcObjPtr->internalRep;
+}
/*
*--------------------------------------------------------------