diff options
author | pooryorick <com.digitalsmarties@pooryorick.com> | 2018-02-15 08:38:27 (GMT) |
---|---|---|
committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2018-02-15 08:38:27 (GMT) |
commit | 2b9b50b436e7b0d4d9463731cc20e85c17dbfca1 (patch) | |
tree | 9893bb853cea60d66b34e1139872defde0a578ff /generic | |
parent | 80fc86a11690b052f4f82b8e6b9e2614d8a0cd59 (diff) | |
download | tcl-2b9b50b436e7b0d4d9463731cc20e85c17dbfca1.zip tcl-2b9b50b436e7b0d4d9463731cc20e85c17dbfca1.tar.gz tcl-2b9b50b436e7b0d4d9463731cc20e85c17dbfca1.tar.bz2 |
Minor refactoring of TclOO object reference count booking during object
creation.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclOO.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c index bc480f5..376f638 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -1677,11 +1677,6 @@ TclNRNewObjectInstance( Tcl_InterpState state; Object *oPtr; - /* - * Protect classPtr from getting cleaned up when the command is created. - */ - AddRef(classPtr); - oPtr = TclNewObjectInstanceCommon(interp, classPtr, nameStr, nsNameStr); if (oPtr == NULL) {return TCL_ERROR;} @@ -1692,13 +1687,11 @@ TclNRNewObjectInstance( if (objc < 0) { *objectPtr = (Tcl_Object) oPtr; - DelRef(classPtr); return TCL_OK; } contextPtr = TclOOGetCallContext(oPtr, NULL, CONSTRUCTOR, NULL); if (contextPtr == NULL) { *objectPtr = (Tcl_Object) oPtr; - DelRef(classPtr); return TCL_OK; } @@ -1722,7 +1715,6 @@ TclNRNewObjectInstance( TclNRAddCallback(interp, FinalizeAlloc, contextPtr, oPtr, state, objectPtr); TclPushTailcallPoint(interp); - DelRef(classPtr); return TclOOInvokeContext(contextPtr, interp, objc, objv); } @@ -1754,7 +1746,15 @@ TclNewObjectInstanceCommon( * Create the object. */ + /* + * The command for the object could have the same name as the command + * associated with classPtr, so protect the structure from deallocation + * here. + */ + AddRef(classPtr); + oPtr = AllocObject(interp, nameStr, nsNameStr); + DelRef(classPtr); oPtr->selfCls = classPtr; TclOOAddToInstances(oPtr, classPtr); |