summaryrefslogtreecommitdiffstats
path: root/generic/tclOOBasic.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-06-27 07:39:49 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-06-27 07:39:49 (GMT)
commit082e8c6d7aa61e4250a321d2d44ca57c8d09049d (patch)
treea9cf328d31c427c99fbec750a99032dd75f341ed /generic/tclOOBasic.c
parent05209c57d377b14758bda3882b0a70b979898066 (diff)
downloadtcl-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.c14
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);
}