diff options
author | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-07-15 13:34:29 (GMT) |
---|---|---|
committer | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-07-17 18:11:25 (GMT) |
commit | 7f04bc3a46d4dd5203b9776c102b487b283a6282 (patch) | |
tree | 4e417b78ed14704d94a1c56ae38411951c27850e | |
parent | 869450c0f6f5cf654211f79d97d00e0d0058b49c (diff) | |
download | Qt-7f04bc3a46d4dd5203b9776c102b487b283a6282.zip Qt-7f04bc3a46d4dd5203b9776c102b487b283a6282.tar.gz Qt-7f04bc3a46d4dd5203b9776c102b487b283a6282.tar.bz2 |
Fix the return value of a constructor that throws an error.
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 2084ddb..c3c7c18 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -2131,8 +2131,10 @@ QScriptValue QScriptValue::construct(const QScriptValueList &args) JSC::ConstructData constructData; JSC::ConstructType constructType = callee.getConstructData(constructData); JSC::JSObject *result = JSC::construct(exec, callee, constructType, constructData, jscArgs); - if (exec->hadException()) + if (exec->hadException()) { eng_p->uncaughtException = exec->exception(); + result = JSC::asObject(exec->exception()); + } return eng_p->scriptValueFromJSCValue(result); } diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 2551e6c..2eff71a 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2593,10 +2593,8 @@ void tst_QScriptValue::construct() QScriptValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); QCOMPARE(fun.isFunction(), true); QScriptValue ret = fun.construct(); - QEXPECT_FAIL("", "Returns null if a constructor throws an error", Continue); QCOMPARE(ret.isError(), true); QCOMPARE(eng.hasUncaughtException(), true); - QEXPECT_FAIL("", "Returns null if a constructor throws an error", Continue); QVERIFY(ret.strictlyEquals(eng.uncaughtException())); } |