diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2016-08-09 10:52:08 +0200 |
|---|---|---|
| committer | Lars Knoll <lars.knoll@qt.io> | 2016-08-09 09:33:55 +0000 |
| commit | 4c47c32c925f0725b57c61875bbb50864032bdd7 (patch) | |
| tree | e1b8ad9b27686bdfdc936b95a4da87e86eeb36fc /src/qml/jsruntime/qv4functionobject.cpp | |
| parent | 5795e059dd40c0feeb3e408d47fa2ff64d56c791 (diff) | |
Fix SimpleScriptFunction::construct
Do the same thing as in ScriptFunction::construct. If
the return value of the call is not an object, return the
this object passed into the function. If an exception got
thrown return undefined.
Fixes the test failures in section 15.3.5 in the JS test suite.
Change-Id: I7a640f3eb0eb7d207ccfa1ff927a46031a6d2c06
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index e1a6bda811..b08ad24fbe 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -548,8 +548,11 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData if (f->function()->compiledFunction->hasQmlDependencies()) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); - if (!scope.result.isManaged() || !scope.result.managed()) + if (v4->hasException) { + scope.result = Encode::undefined(); + } else if (!scope.result.isObject()) { scope.result = callData->thisObject; + } } void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) |
