aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsapi/qjsengine.cpp2
-rw-r--r--src/qml/jsapi/qjsvalue.cpp75
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp3
-rw-r--r--src/qml/jsruntime/qv4context.cpp5
-rw-r--r--src/qml/jsruntime/qv4context_p.h3
-rw-r--r--src/qml/jsruntime/qv4debugging.cpp2
-rw-r--r--src/qml/jsruntime/qv4engine.cpp12
-rw-r--r--src/qml/jsruntime/qv4engine_p.h4
-rw-r--r--src/qml/jsruntime/qv4include.cpp9
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp3
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp4
-rw-r--r--src/qml/jsruntime/qv4script.cpp3
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp3
-rw-r--r--src/qml/jsruntime/qv4value.cpp4
-rw-r--r--src/qml/qml/qqmlcomponent.cpp3
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp10
-rw-r--r--src/qml/qml/qqmltypeloader.cpp3
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp3
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp3
-rw-r--r--src/qml/types/qquickworkerscript.cpp9
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp12
-rw-r--r--tools/qmljs/qmljs.cpp2
22 files changed, 67 insertions, 110 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index 0d2b394cd6..427575b386 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -307,7 +307,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
if (!scope.engine->hasException)
result = script.run();
if (scope.engine->hasException)
- result = ctx->catchException();
+ result = v4->catchException();
if (ctx != v4->rootContext)
v4->popContext();
return new QJSValuePrivate(v4, result);
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 5f76ba2c52..9089fffc74 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -394,10 +394,9 @@ double QJSValue::toNumber() const
return std::numeric_limits<double>::quiet_NaN();
}
- QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
double dbl = d->value.toNumber();
- if (ctx && ctx->d()->engine->hasException) {
- ctx->catchException();
+ if (d->engine && d->engine->hasException) {
+ d->engine->catchException();
return 0;
}
return dbl;
@@ -424,10 +423,9 @@ bool QJSValue::toBool() const
return d->unboundData.toBool();
}
- QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
bool b = d->value.toBoolean();
- if (ctx && ctx->d()->engine->hasException) {
- ctx->catchException();
+ if (d->engine && d->engine->hasException) {
+ d->engine->catchException();
return false;
}
return b;
@@ -454,10 +452,9 @@ qint32 QJSValue::toInt() const
return d->unboundData.toInt();
}
- QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
qint32 i = d->value.toInt32();
- if (ctx && ctx->d()->engine->hasException) {
- ctx->catchException();
+ if (d->engine && d->engine->hasException) {
+ d->engine->catchException();
return 0;
}
return i;
@@ -484,10 +481,9 @@ quint32 QJSValue::toUInt() const
return d->unboundData.toUInt();
}
- QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0;
quint32 u = d->value.toUInt32();
- if (ctx && ctx->d()->engine->hasException) {
- ctx->catchException();
+ if (d->engine && d->engine->hasException) {
+ d->engine->catchException();
return 0;
}
return u;
@@ -558,11 +554,9 @@ QJSValue QJSValue::call(const QJSValueList &args)
callData->args[i] = args.at(i).d->getValue(engine);
}
- ScopedValue result(scope);
- QV4::ExecutionContext *ctx = engine->currentContext();
- result = f->call(callData);
- if (scope.hasException())
- result = ctx->catchException();
+ ScopedValue result(scope, f->call(callData));
+ if (d->engine->hasException)
+ result = d->engine->catchException();
return new QJSValuePrivate(engine, result);
}
@@ -612,11 +606,9 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList
callData->args[i] = args.at(i).d->getValue(engine);
}
- ScopedValue result(scope);
- QV4::ExecutionContext *ctx = engine->currentContext();
- result = f->call(callData);
- if (scope.hasException())
- result = ctx->catchException();
+ ScopedValue result(scope, f->call(callData));
+ if (d->engine->hasException)
+ result = d->engine->catchException();
return new QJSValuePrivate(engine, result);
}
@@ -658,11 +650,9 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
callData->args[i] = args.at(i).d->getValue(engine);
}
- ScopedValue result(scope);
- QV4::ExecutionContext *ctx = engine->currentContext();
- result = f->construct(callData);
- if (scope.hasException())
- result = ctx->catchException();
+ ScopedValue result(scope, f->construct(callData));
+ if (d->engine->hasException)
+ result = d->engine->catchException();
return new QJSValuePrivate(engine, result);
}
@@ -886,11 +876,9 @@ QJSValue QJSValue::property(const QString& name) const
return property(idx);
s->makeIdentifier();
- QV4::ExecutionContext *ctx = engine->currentContext();
- QV4::ScopedValue result(scope);
- result = o->get(s.getPointer());
- if (scope.hasException())
- result = ctx->catchException();
+ QV4::ScopedValue result(scope, o->get(s));
+ if (d->engine->hasException)
+ result = d->engine->catchException();
return new QJSValuePrivate(engine, result);
}
@@ -918,11 +906,9 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
if (!o)
return QJSValue();
- QV4::ExecutionContext *ctx = engine->currentContext();
- QV4::ScopedValue result(scope);
- result = arrayIndex == UINT_MAX ? o->get(engine->id_uintMax.getPointer()) : o->getIndexed(arrayIndex);
- if (scope.hasException())
- result = ctx->catchException();
+ QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax.getPointer()) : o->getIndexed(arrayIndex));
+ if (d->engine->hasException)
+ d->engine->catchException();
return new QJSValuePrivate(engine, result);
}
@@ -960,12 +946,11 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value)
return;
}
- QV4::ExecutionContext *ctx = engine->currentContext();
s->makeIdentifier();
QV4::ScopedValue v(scope, value.d->getValue(engine));
o->put(s.getPointer(), v);
- if (scope.hasException())
- ctx->catchException();
+ if (d->engine->hasException)
+ d->engine->catchException();
}
/*!
@@ -991,14 +976,13 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
if (!o)
return;
- QV4::ExecutionContext *ctx = engine->currentContext();
QV4::ScopedValue v(scope, value.d->getValue(engine));
if (arrayIndex != UINT_MAX)
o->putIndexed(arrayIndex, v);
else
o->put(engine->id_uintMax.getPointer(), v);
- if (scope.hasException())
- ctx->catchException();
+ if (d->engine->hasException)
+ d->engine->catchException();
}
/*!
@@ -1024,7 +1008,6 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
bool QJSValue::deleteProperty(const QString &name)
{
ExecutionEngine *engine = d->engine;
- ExecutionContext *ctx = engine->currentContext();
Scope scope(engine);
ScopedObject o(scope, d->value.asObject());
if (!o)
@@ -1032,8 +1015,8 @@ bool QJSValue::deleteProperty(const QString &name)
ScopedString s(scope, engine->newString(name));
bool b = o->deleteProperty(s.getPointer());
- if (scope.hasException())
- ctx->catchException();
+ if (d->engine->hasException)
+ d->engine->catchException();
return b;
}
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index cc6953cbf7..7eb1de45b1 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -190,13 +190,12 @@ QJSValue QJSValueIterator::value() const
if (!obj)
return QJSValue();
- QV4::ExecutionContext *ctx = engine->currentContext();
if (!d_ptr->currentName && d_ptr->currentIndex == UINT_MAX)
return QJSValue();
QV4::ScopedValue v(scope, obj->getValue(obj, &d_ptr->currentProperty, d_ptr->currentAttributes));
if (scope.hasException()) {
- ctx->catchException();
+ engine->catchException();
return QJSValue();
}
return new QJSValuePrivate(engine, v);
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 6d0471771f..184d47db32 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -473,8 +473,3 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object *&base)
ScopedValue n(scope, name);
return engine()->throwReferenceError(n);
}
-
-ReturnedValue ExecutionContext::catchException(StackTrace *trace)
-{
- return d()->engine->catchException(this, trace);
-}
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 30b578e428..298ac0acb4 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -142,9 +142,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
ReturnedValue getPropertyAndBase(String *name, Object *&base);
bool deleteProperty(String *name);
- // Can only be called from within catch(...), rethrows if no JS exception.
- ReturnedValue catchException(StackTrace *trace = 0);
-
inline CallContext *asCallContext();
inline const CallContext *asCallContext() const;
diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp
index c906fb3581..85c03914a7 100644
--- a/src/qml/jsruntime/qv4debugging.cpp
+++ b/src/qml/jsruntime/qv4debugging.cpp
@@ -72,7 +72,7 @@ public:
if (!scope.engine->hasException)
result = script.run();
if (scope.engine->hasException)
- result = ctx->catchException();
+ result = scope.engine->catchException();
handleResult(result);
}
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 1080831ee7..78da27683d 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -998,11 +998,9 @@ ReturnedValue ExecutionEngine::throwError(const ValueRef value)
return Encode::undefined();
}
-ReturnedValue ExecutionEngine::catchException(ExecutionContext *catchingContext, StackTrace *trace)
+ReturnedValue ExecutionEngine::catchException(StackTrace *trace)
{
Q_ASSERT(hasException);
- Q_UNUSED(catchingContext);
- Q_ASSERT(currentContext() == catchingContext);
if (trace)
*trace = exceptionStackTrace;
exceptionStackTrace.clear();
@@ -1098,11 +1096,11 @@ ReturnedValue ExecutionEngine::throwUnimplemented(const QString &message)
}
-QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context)
+QQmlError ExecutionEngine::catchExceptionAsQmlError()
{
QV4::StackTrace trace;
- QV4::Scope scope(context);
- QV4::ScopedValue exception(scope, context->catchException(&trace));
+ QV4::Scope scope(this);
+ QV4::ScopedValue exception(scope, catchException(&trace));
QQmlError error;
if (!trace.isEmpty()) {
QV4::StackFrame frame = trace.first();
@@ -1112,7 +1110,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context)
}
QV4::Scoped<QV4::ErrorObject> errorObj(scope, exception);
if (!!errorObj && errorObj->asSyntaxError()) {
- QV4::ScopedString m(scope, errorObj->engine()->newString(QStringLiteral("message")));
+ QV4::ScopedString m(scope, newString(QStringLiteral("message")));
QV4::ScopedValue v(scope, errorObj->get(m.getPointer()));
error.setDescription(v->toQStringNoThrow());
} else
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index b4219a9826..d3c0cf43d0 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -363,7 +363,7 @@ public:
StackTrace exceptionStackTrace;
ReturnedValue throwError(const ValueRef value);
- ReturnedValue catchException(ExecutionContext *catchingContext, StackTrace *trace);
+ ReturnedValue catchException(StackTrace *trace = 0);
ReturnedValue throwError(const QString &message);
ReturnedValue throwSyntaxError(const QString &message);
@@ -378,7 +378,7 @@ public:
ReturnedValue throwUnimplemented(const QString &message);
// Use only inside catch(...) -- will re-throw if no JS exception
- static QQmlError catchExceptionAsQmlError(QV4::ExecutionContext *context);
+ QQmlError catchExceptionAsQmlError();
private:
QmlExtensions *m_qmlExtensions;
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp
index 60ac519dfb..67282f25ac 100644
--- a/src/qml/jsruntime/qv4include.cpp
+++ b/src/qml/jsruntime/qv4include.cpp
@@ -100,13 +100,12 @@ void QV4Include::callback(const QV4::ValueRef callback, const QV4::ValueRef stat
if (!f)
return;
- QV4::ExecutionContext *ctx = v4->currentContext();
QV4::ScopedCallData callData(scope, 1);
callData->thisObject = v4->globalObject->asReturnedValue();
callData->args[0] = status;
f->call(callData);
if (scope.hasException())
- ctx->catchException();
+ scope.engine->catchException();
}
QV4::ReturnedValue QV4Include::result()
@@ -146,12 +145,11 @@ void QV4Include::finished()
QV4::ScopedObject qmlglobal(scope, m_qmlglobal.value());
QV4::Script script(v4, qmlglobal, code, m_url.toString());
- QV4::ExecutionContext *ctx = v4->currentContext();
script.parse();
if (!scope.engine->hasException)
script.run();
if (scope.engine->hasException) {
- QV4::ScopedValue ex(scope, ctx->catchException());
+ QV4::ScopedValue ex(scope, scope.engine->catchException());
resultObj->put(status.getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception)));
QV4::ScopedString exception(scope, v4->newString(QStringLiteral("exception")));
resultObj->put(exception.getPointer(), ex);
@@ -220,12 +218,11 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx)
}
if (!script.isNull()) {
- QV4::ExecutionContext *ctx = scope.engine->currentContext();
script->parse();
if (!scope.engine->hasException)
script->run();
if (scope.engine->hasException) {
- QV4::ScopedValue ex(scope, ctx->catchException());
+ QV4::ScopedValue ex(scope, scope.engine->catchException());
result = resultValue(scope.engine, Exception);
QV4::ScopedString exception(scope, scope.engine->newString(QStringLiteral("exception")));
result->asObject()->put(exception.getPointer(), ex);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 0ea43b9b06..147f27ee37 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -795,7 +795,6 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
QV4::Scope scope(v4);
QV4::ScopedFunctionObject f(scope, This->function.value());
- QV4::ExecutionContext *ctx = v4->currentContext();
QV4::ScopedCallData callData(scope, argCount);
callData->thisObject = This->thisObject.isUndefined() ? v4->globalObject->asReturnedValue() : This->thisObject.value();
@@ -811,7 +810,7 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase
f->call(callData);
if (scope.hasException() && v4->v8Engine) {
if (QQmlEngine *qmlEngine = v4->v8Engine->engine()) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = v4->catchExceptionAsQmlError();
if (error.description().isEmpty()) {
QV4::ScopedString name(scope, f->name());
error.setDescription(QString(QLatin1String("Unknown exception occurred during evaluation of connected function: %1")).arg(name->toQString()));
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index db82efa087..e4f97b2000 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1126,13 +1126,13 @@ ReturnedValue Runtime::unwindException(ExecutionEngine *engine)
{
if (!engine->hasException)
return Primitive::emptyValue().asReturnedValue();
- return engine->catchException(engine->currentContext(), 0);
+ return engine->catchException(0);
}
void Runtime::pushCatchScope(NoThrowEngine *engine, String *exceptionVarName)
{
Scope scope(engine);
- ScopedValue v(scope, engine->catchException(engine->currentContext(), 0));
+ ScopedValue v(scope, engine->catchException(0));
engine->currentContext()->newCatchContext(exceptionVarName, v);
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index e7bfed633b..07e6035380 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -395,13 +395,12 @@ QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &scr
QV4::Scope scope(engine);
QV4::Script qmlScript(engine, scopeObject, script, QString());
- QV4::ExecutionContext *ctx = engine->currentContext();
qmlScript.parse();
QV4::ScopedValue result(scope);
if (!scope.engine->hasException)
result = qmlScript.run();
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return Encode::undefined();
}
return result.asReturnedValue();
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index 4b93afbc3a..33d65fbd8f 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -271,11 +271,10 @@ void Serialize::serialize(QByteArray &data, const QV4::ValueRef v, QV8Engine *en
s = properties->getIndexed(ii);
serialize(data, s, engine);
- QV4::ExecutionContext *ctx = v4->currentContext();
str = s;
val = o->get(str.getPointer());
if (scope.hasException())
- ctx->catchException();
+ scope.engine->catchException();
serialize(data, val, engine);
}
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 3d40f4b7f5..cd44d93f42 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -130,7 +130,7 @@ QString Value::toQStringNoThrow() const
bool caughtException = false;
ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT));
if (scope.hasException()) {
- ex = ctx->catchException();
+ ex = scope.engine->catchException();
caughtException = true;
} else if (prim->isPrimitive()) {
return prim->toQStringNoThrow();
@@ -139,7 +139,7 @@ QString Value::toQStringNoThrow() const
if (caughtException) {
ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ex, STRING_HINT));
if (scope.hasException()) {
- ex = ctx->catchException();
+ ex = scope.engine->catchException();
} else if (prim->isPrimitive()) {
return prim->toQStringNoThrow();
}
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index a408072d38..33cffe6629 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1535,13 +1535,12 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s)
QV4::ScopedFunctionObject f(scope, d()->statusChanged);
if (f) {
- QV4::ExecutionContext *ctx = scope.engine->currentContext();
QV4::ScopedCallData callData(scope, 1);
callData->thisObject = this;
callData->args[0] = QV4::Primitive::fromUInt32(s);
f->call(callData);
if (scope.hasException()) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = scope.engine->catchExceptionAsQmlError();
QQmlEnginePrivate::warning(QQmlEnginePrivate::get(d()->v8->engine()), error);
}
}
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 7425509b40..55fc193abd 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -78,7 +78,7 @@ void QQmlDelayedError::setErrorObject(QObject *object)
void QQmlDelayedError::catchJavaScriptException(QV4::ExecutionContext *context)
{
- m_error = QV4::ExecutionEngine::catchExceptionAsQmlError(context);
+ m_error = context->engine()->catchExceptionAsQmlError();
}
@@ -158,7 +158,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context,
result = function->asFunctionObject()->call(callData);
if (scope.hasException()) {
if (watcher.wasDeleted())
- ctx->catchException(); // ignore exception
+ scope.engine->catchException(); // ignore exception
else
delayedError()->catchJavaScriptException(ctx);
if (isUndefined)
@@ -288,7 +288,6 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
- QV4::ExecutionContext *ctx = v4->currentContext();
QV4::Scope scope(v4);
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, scopeObject));
@@ -298,7 +297,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje
if (!v4->hasException)
result = script.run();
if (v4->hasException) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = v4->catchExceptionAsQmlError();
if (error.description().isEmpty())
error.setDescription(QLatin1String("Exception occurred during function evaluation"));
if (error.line() == -1)
@@ -322,7 +321,6 @@ QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, Q
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
- QV4::ExecutionContext *ctx = v4->currentContext();
QV4::Scope scope(v4);
QV4::ScopedObject qmlScopeObject(scope, QV4::QmlContextWrapper::qmlScope(ep->v8engine(), ctxt, qmlScope));
@@ -332,7 +330,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, Q
if (!v4->hasException)
result = script.qmlBinding();
if (v4->hasException) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = v4->catchExceptionAsQmlError();
if (error.description().isEmpty())
error.setDescription(QLatin1String("Exception occurred during function evaluation"));
if (error.line() == -1)
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 1b222fe1a3..bfdf862c7b 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2638,11 +2638,10 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare
QV4::ScopedValue qmlglobal(scope, QV4::QmlContextWrapper::qmlScope(v8engine, ctxt, 0));
QV4::QmlContextWrapper::takeContextOwnership(qmlglobal);
- QV4::ExecutionContext *ctx = QV8Engine::getV4(v8engine)->currentContext();
m_program->qml = qmlglobal;
m_program->run();
if (scope.engine->hasException) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = scope.engine->catchExceptionAsQmlError();
if (error.isValid())
ep->warning(error);
}
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index f6d72c00b1..622e05fe7c 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -948,10 +948,9 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
callData->args[ii] = ep->v8engine()->fromVariant(*(QVariant *)a[ii + 1]);
QV4::ScopedValue result(scope);
- QV4::ExecutionContext *ctx = function->engine()->currentContext();
result = function->call(callData);
if (scope.hasException()) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = scope.engine->catchExceptionAsQmlError();
if (error.isValid())
ep->warning(error);
if (a[0]) *(QVariant *)a[0] = QVariant();
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 1566971827..9b1607c7ad 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1592,10 +1592,9 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me)
void QQmlXMLHttpRequest::dispatchCallback(const ValueRef me)
{
- ExecutionContext *ctx = v4->currentContext();
dispatchCallbackImpl(me);
if (v4->hasException) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = v4->catchExceptionAsQmlError();
QQmlEnginePrivate::warning(QQmlEnginePrivate::get(v4->v8Engine->engine()), error);
}
}
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index f2705aca44..1640a1ffcf 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -244,7 +244,6 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i
QV4::Scope scope(v4);
QV4::ScopedFunctionObject f(scope, createsend.value());
- QV4::ExecutionContext *ctx = v4->currentContext();
QV4::ScopedValue v(scope);
QV4::ScopedCallData callData(scope, 1);
@@ -252,7 +251,7 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::WorkerEngine::sendFunction(i
callData->thisObject = global();
v = f->call(callData);
if (scope.hasException())
- v = ctx->catchException();
+ v = scope.engine->catchException();
return v.asReturnedValue();
}
@@ -352,7 +351,6 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d
QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
QV4::Scope scope(v4);
QV4::ScopedFunctionObject f(scope, workerEngine->onmessage.value());
- QV4::ExecutionContext *ctx = v4->currentContext();
QV4::ScopedValue value(scope, QV4::Serialize::deserialize(data, workerEngine));
@@ -362,7 +360,7 @@ void QQuickWorkerScriptEnginePrivate::processMessage(int id, const QByteArray &d
callData->args[1] = value;
f->call(callData);
if (scope.hasException()) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = scope.engine->catchExceptionAsQmlError();
reportScriptException(script, error);
}
}
@@ -409,8 +407,7 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
program->run();
if (v4->hasException) {
- QV4::ExecutionContext *ctx = v4->currentContext();
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ QQmlError error = v4->catchExceptionAsQmlError();
reportScriptException(script, error);
}
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 30a01188fe..0f1e77a7a5 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -2308,7 +2308,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons
QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return true;
}
QV4::ScopedCallData d(scope, 1);
@@ -2316,7 +2316,7 @@ static inline bool evaluate_error(QV8Engine *engine, const QV4::ValueRef o, cons
d->thisObject = engine->global();
function->call(d);
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return true;
}
return false;
@@ -2336,7 +2336,7 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return false;
}
if (!function)
@@ -2348,7 +2348,7 @@ static inline bool evaluate_value(QV8Engine *engine, const QV4::ValueRef o,
d->thisObject = engine->global();
value = function->call(d);
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return false;
}
return QV4::Runtime::strictEqual(value, result);
@@ -2368,7 +2368,7 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef
QV4::Scoped<QV4::FunctionObject> function(scope, program.run());
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return QV4::Encode::undefined();
}
if (!function)
@@ -2378,7 +2378,7 @@ static inline QV4::ReturnedValue evaluate(QV8Engine *engine, const QV4::ValueRef
d->thisObject = engine->global();
QV4::ScopedValue result(scope, function->call(d));
if (scope.engine->hasException) {
- ctx->catchException();
+ scope.engine->catchException();
return QV4::Encode::undefined();
}
return result.asReturnedValue();
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 8e270fc61b..5d7d065b50 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
result = script.run();
if (scope.engine->hasException) {
QV4::StackTrace trace;
- QV4::ScopedValue ex(scope, ctx->catchException(&trace));
+ QV4::ScopedValue ex(scope, scope.engine->catchException(&trace));
showException(ctx, ex, trace);
return EXIT_FAILURE;
}