summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptvalue.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-23 15:19:53 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-24 08:43:16 (GMT)
commitba2432acf72a0649f0f841759a61ec246c5a9b1f (patch)
tree0021f53a7f24cc08d845e6bfa162b725db29644b /src/script/api/qscriptvalue.cpp
parent2ce65133026e1f291f7b6b312d832acb0a4045ae (diff)
downloadQt-ba2432acf72a0649f0f841759a61ec246c5a9b1f.zip
Qt-ba2432acf72a0649f0f841759a61ec246c5a9b1f.tar.gz
Qt-ba2432acf72a0649f0f841759a61ec246c5a9b1f.tar.bz2
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
Diffstat (limited to 'src/script/api/qscriptvalue.cpp')
-rw-r--r--src/script/api/qscriptvalue.cpp28
1 files 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);
}