diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-08-14 10:53:39 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-08-14 10:53:39 (GMT) |
commit | 57cdbb1b09c712d6381bb80eda7f88fbbc0d3ca1 (patch) | |
tree | c94eb9ac635555edd735af8a8e6f8f7fddb363fe | |
parent | 2d75f48b464158f2c0350d6b3e15711646483291 (diff) | |
download | tk-57cdbb1b09c712d6381bb80eda7f88fbbc0d3ca1.zip tk-57cdbb1b09c712d6381bb80eda7f88fbbc0d3ca1.tar.gz tk-57cdbb1b09c712d6381bb80eda7f88fbbc0d3ca1.tar.bz2 |
Fix reference counting for "option" objects, when being duplicated.
-rw-r--r-- | generic/tkConfig.c | 25 |
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; +} /* *-------------------------------------------------------------- |