From ba2432acf72a0649f0f841759a61ec246c5a9b1f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 23 Jul 2009 17:19:53 +0200 Subject: Clear the exceptions before calling a function. So the exception we get as result are the one thrown by the function. (fix tst_QScriptEngine::newRegExp test) Reviewed-by: Kent Hansen --- src/script/api/qscriptvalue.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 0fe6825..1082fa3 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -2005,10 +2005,15 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, JSC::JSValue callee = d->jscValue; JSC::CallData callData; JSC::CallType callType = callee.getCallData(callData); + JSC::JSValue savedException; + QScriptValuePrivate::saveException(exec, &savedException); JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, jscArgs); if (exec->hadException()) { - eng_p->uncaughtException = exec->exception(); + if (!eng_p->uncaughtException) + eng_p->uncaughtException = exec->exception(); result = exec->exception(); + } else { + QScriptValuePrivate::restoreException(exec, savedException); } return eng_p->scriptValueFromJSCValue(result); } @@ -2081,10 +2086,15 @@ QScriptValue QScriptValue::call(const QScriptValue &thisObject, JSC::JSValue callee = d->jscValue; JSC::CallData callData; JSC::CallType callType = callee.getCallData(callData); + JSC::JSValue savedException; + QScriptValuePrivate::saveException(exec, &savedException); JSC::JSValue result = JSC::call(exec, callee, callType, callData, jscThisObject, applyArgs); if (exec->hadException()) { - eng_p->uncaughtException = exec->exception(); + if (!eng_p->uncaughtException) + eng_p->uncaughtException = exec->exception(); result = exec->exception(); + } else { + QScriptValuePrivate::restoreException(exec, savedException); } return eng_p->scriptValueFromJSCValue(result); } @@ -2128,10 +2138,15 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args) JSC::JSValue callee = d->jscValue; JSC::ConstructData constructData; JSC::ConstructType constructType = callee.getConstructData(constructData); + JSC::JSValue savedException; + QScriptValuePrivate::saveException(exec, &savedException); JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs); if (exec->hadException()) { - eng_p->uncaughtException = exec->exception(); + if (!eng_p->uncaughtException) + eng_p->uncaughtException = exec->exception(); result = JSC::asObject(exec->exception()); + } else { + QScriptValuePrivate::restoreException(exec, savedException); } return eng_p->scriptValueFromJSCValue(result); } @@ -2182,11 +2197,16 @@ QScriptValue QScriptValue::construct(const QScriptValue &arguments) JSC::JSValue callee = d->jscValue; JSC::ConstructData constructData; JSC::ConstructType constructType = callee.getConstructData(constructData); + JSC::JSValue savedException; + QScriptValuePrivate::saveException(exec, &savedException); JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, applyArgs); if (exec->hadException()) { - eng_p->uncaughtException = exec->exception(); + if (!eng_p->uncaughtException) + eng_p->uncaughtException = exec->exception(); if (exec->exception().isObject()) result = JSC::asObject(exec->exception()); + } else { + QScriptValuePrivate::restoreException(exec, savedException); } return eng_p->scriptValueFromJSCValue(result); } -- cgit v0.12