diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2018-06-27 07:39:49 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2018-06-27 07:39:49 (GMT) |
commit | 082e8c6d7aa61e4250a321d2d44ca57c8d09049d (patch) | |
tree | a9cf328d31c427c99fbec750a99032dd75f341ed /generic/tclOOBasic.c | |
parent | 05209c57d377b14758bda3882b0a70b979898066 (diff) | |
download | tcl-082e8c6d7aa61e4250a321d2d44ca57c8d09049d.zip tcl-082e8c6d7aa61e4250a321d2d44ca57c8d09049d.tar.gz tcl-082e8c6d7aa61e4250a321d2d44ca57c8d09049d.tar.bz2 |
Add better error handling and make the delegation work with cloning.
Diffstat (limited to 'generic/tclOOBasic.c')
-rw-r--r-- | generic/tclOOBasic.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/generic/tclOOBasic.c b/generic/tclOOBasic.c index 54115e0..13c98f4 100644 --- a/generic/tclOOBasic.c +++ b/generic/tclOOBasic.c @@ -122,7 +122,7 @@ TclOO_Class_Constructor( Tcl_IncrRefCount(invoke[1]); Tcl_IncrRefCount(invoke[2]); TclNRAddCallback(interp, DecrRefsPostClassConstructor, - invoke, NULL, NULL, NULL); + invoke, oPtr, NULL, NULL); /* * Tricky point: do not want the extra reported level in the Tcl stack @@ -139,16 +139,26 @@ DecrRefsPostClassConstructor( int result) { Tcl_Obj **invoke = data[0]; + Object *oPtr = data[1]; Tcl_InterpState saved; + int code; TclDecrRefCount(invoke[0]); + TclDecrRefCount(invoke[1]); TclDecrRefCount(invoke[2]); invoke[0] = Tcl_NewStringObj("::oo::MixinClassDelegates", -1); + invoke[1] = TclOOObjectName(interp, oPtr); Tcl_IncrRefCount(invoke[0]); + Tcl_IncrRefCount(invoke[1]); saved = Tcl_SaveInterpState(interp, result); - Tcl_EvalObjv(interp, 2, invoke, 0); + code = Tcl_EvalObjv(interp, 2, invoke, 0); + TclDecrRefCount(invoke[0]); TclDecrRefCount(invoke[1]); ckfree(invoke); + if (code != TCL_OK) { + Tcl_DiscardInterpState(saved); + return code; + } return Tcl_RestoreInterpState(interp, saved); } |