From 58dbd9c74f398b030c44ec2bc6af99af2edd913a Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 15 Jul 2009 10:08:59 +0200 Subject: clear script exceptions when executing Qt methods The argument conversion logic checks for exceptions after attempting to convert each argument; this requires that there is initially no exception, otherwise it's going to bail out even if the conversion itself succeeded. --- src/script/bridge/qscriptqobject.cpp | 2 ++ tests/auto/qscriptengine/tst_qscriptengine.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index ff58102..0f54ec9 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -496,6 +496,8 @@ JSC::JSValue QtFunction::execute(JSC::ExecState *exec, JSC::JSValue thisValue, thisQObject = qobj; } + exec->clearException(); + QByteArray funName; QScriptMetaMethod chosenMethod; int chosenIndex = -1; diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 49e80b5..8e250d1 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1776,6 +1776,7 @@ void tst_QScriptEngine::castWithPrototypeChain() { QScriptValue ret = toBaz.call(scriptZoo, QScriptValueList() << baz2Value); QVERIFY(ret.isError()); + QEXPECT_FAIL("", "Should give an error message ('Incompatible type of argument(s) ...')", Continue); QCOMPARE(ret.toString(), QLatin1String("TypeError: incompatible type of argument(s) in call to toBaz(); candidates were\n toBaz(Bar*)")); } -- cgit v0.12