From af22149dd8daf593182fec978f15dc1667c9cf8d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 21 Oct 2013 09:57:58 +0200 Subject: Avoid side effects when en exception has been thrown. We don't want to check for exceptions after every single line on our runtime methods. A better way to handle this is to add the check in all methods that have direct side effects (as e.g. writing to a property of the JS stack). We also need to return whereever we throw an exception. To simplify the code, ExecutionContext::throwXxx methods now return a ReturnedValue (always undefined) for convenience. Change-Id: Ide6c804f819c731a3f14c6c43121d08029c9fb90 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4errorobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/qml/jsruntime/qv4errorobject.cpp') diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index ef9dc473f3..12ac4218bd 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -172,7 +172,7 @@ ReturnedValue ErrorObject::method_get_stack(SimpleCallContext *ctx) Scope scope(ctx); Scoped This(scope, ctx->callData->thisObject); if (!This) - ctx->throwTypeError(); + return ctx->throwTypeError(); if (!This->stack) { QString trace; for (int i = 0; i < This->stackTrace.count(); ++i) { @@ -389,7 +389,7 @@ ReturnedValue ErrorPrototype::method_toString(SimpleCallContext *ctx) Object *o = ctx->callData->thisObject.asObject(); if (!o) - ctx->throwTypeError(); + return ctx->throwTypeError(); ScopedValue name(scope, o->get(ctx->engine->id_name)); QString qname; -- cgit v1.2.3