aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-07 10:23:13 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-07 10:32:04 +0000
commit06e0ec7cfc6e990c1101a2b4c15452d3c10b6816 (patch)
treeb82116cf9bb139ffdfd257a6c53e71866d1e4a57 /src/qml/jsruntime/qv4runtime.cpp
parentff5bc526b4868aef9fb3a551afc5636b308a3d83 (diff)
Fix a smaller bug in IteratorClose
Throw the correct error in all cases Change-Id: Ic8f146cf13db605cb54cb8c96aaf0b3a1b9cca96 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index b59b9c3f50..4e1993d45f 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -862,29 +862,36 @@ ReturnedValue Runtime::method_iteratorClose(ExecutionEngine *engine, const Value
return Encode::undefined();
Scope scope(engine);
- bool hadException = engine->hasException;
ScopedValue e(scope);
+ bool hadException = engine->hasException;
if (hadException) {
e = *engine->exceptionValue;
engine->hasException = false;
}
- ScopedFunctionObject f(scope, static_cast<const Object &>(iterator).get(engine->id_return()));
- ScopedObject o(scope);
- if (f) {
- JSCallData cData(scope, 0, nullptr, &iterator);
- o = f->call(cData);
- }
- if (hadException || !f) {
- *engine->exceptionValue = e;
- engine->hasException = hadException;
+
+ auto originalCompletion = [=]() {
+ if (hadException) {
+ *engine->exceptionValue = e;
+ engine->hasException = hadException;
+ }
return Encode::undefined();
+ };
+
+ ScopedValue ret(scope, static_cast<const Object &>(iterator).get(engine->id_return()));
+ ScopedObject o(scope);
+ if (!ret->isUndefined()) {
+ FunctionObject *f = ret->as<FunctionObject>();
+ o = f->call(&iterator, nullptr, 0);
+ if (engine->hasException && !hadException)
+ return Encode::undefined();
}
- if (engine->hasException)
- return Encode::undefined();
+ if (hadException || ret->isUndefined())
+ return originalCompletion();
if (!o)
return engine->throwTypeError();
- return Encode::undefined();
+
+ return originalCompletion();
}
ReturnedValue Runtime::method_destructureRestElement(ExecutionEngine *engine, const Value &iterator)