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/particles/qquickv4particledata.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/particles') diff --git a/src/particles/qquickv4particledata.cpp b/src/particles/qquickv4particledata.cpp index 3cfce0ae90..0524a5a871 100644 --- a/src/particles/qquickv4particledata.cpp +++ b/src/particles/qquickv4particledata.cpp @@ -304,7 +304,7 @@ static QV4::ReturnedValue particleData_discard(QV4::SimpleCallContext *ctx) QV4::Scoped r(scope, ctx->callData->thisObject); if (!r || !r->datum) - ctx->throwError(QStringLiteral("Not a valid ParticleData object")); + return ctx->throwError(QStringLiteral("Not a valid ParticleData object")); r->datum->lifeSpan = 0; //Don't kill(), because it could still be in the middle of being created return QV4::Encode::undefined(); @@ -316,7 +316,7 @@ static QV4::ReturnedValue particleData_lifeLeft(QV4::SimpleCallContext *ctx) QV4::Scoped r(scope, ctx->callData->thisObject); if (!r || !r->datum) - ctx->throwError(QStringLiteral("Not a valid ParticleData object")); + return ctx->throwError(QStringLiteral("Not a valid ParticleData object")); return QV4::Encode(r->datum->lifeLeft()); } @@ -327,7 +327,7 @@ static QV4::ReturnedValue particleData_curSize(QV4::SimpleCallContext *ctx) QV4::Scoped r(scope, ctx->callData->thisObject); if (!r || !r->datum) - ctx->throwError(QStringLiteral("Not a valid ParticleData object")); + return ctx->throwError(QStringLiteral("Not a valid ParticleData object")); return QV4::Encode(r->datum->curSize()); } -- cgit v1.2.3