aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmljavascriptexpression.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-05-20 23:51:45 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-05-21 10:11:43 +0200
commit7fe54ee6d6eb44c630038229eb9a4bb1780eec77 (patch)
tree20e0278387688936a060eaed33273ca7bb5e89c5 /src/qml/qml/qqmljavascriptexpression.cpp
parente1a6612d3a4528fee8854c274232fc4966d65237 (diff)
Convert the remaining TryCatch statements to use QV4::Exception
v8::Script::Run doesn't catch the exception anymore. Instead we handle this on the calling side, removing all needs for v8::TryCatch. Change-Id: I946269a6734f50c728c4f153c00cd19db48f1a6a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmljavascriptexpression.cpp')
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp77
1 files changed, 33 insertions, 44 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 7aa7234197..e5525e59a3 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -339,29 +339,24 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
QQmlEngine *engine = ctxt->engine;
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
- v8::TryCatch tc;
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
+ QV4::ExecutionContext *ctx = v4->current;
+
v8::Handle<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
v8::Handle<v8::Script> script = ep->v8engine()->qmlModeCompile(code, codeLength, filename, line);
- if (tc.HasCaught()) {
- QQmlError error;
- error.setDescription(QLatin1String("Exception occurred during function compilation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Handle<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QQmlExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- return QV4::PersistentValue();
- }
- v8::Handle<v8::Value> result = script->Run(scopeobject);
- if (tc.HasCaught()) {
+ v8::Handle<v8::Value> result;
+ try {
+ result = script->Run(scopeobject);
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
QQmlError error;
- error.setDescription(QLatin1String("Exception occurred during function evaluation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Handle<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QQmlExpressionPrivate::exceptionToError(message, error);
+ QQmlExpressionPrivate::exceptionToError(e, error);
+ if (error.description().isEmpty())
+ error.setDescription(QLatin1String("Exception occurred during function evaluation"));
+ if (error.line() == -1)
+ error.setLine(line);
+ if (error.url().isEmpty())
+ error.setUrl(QUrl::fromLocalFile(filename));
ep->warning(error);
return QV4::PersistentValue();
}
@@ -379,35 +374,29 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope,
QQmlEngine *engine = ctxt->engine;
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine);
- v8::TryCatch tc;
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine());
+ QV4::ExecutionContext *ctx = v4->current;
+
v8::Handle<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope);
v8::Handle<v8::Script> script = ep->v8engine()->qmlModeCompile(code, filename, line);
- if (tc.HasCaught()) {
- QQmlError error;
- error.setDescription(QLatin1String("Exception occurred during function compilation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Handle<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QQmlExpressionPrivate::exceptionToError(message, error);
- ep->warning(error);
- return QV4::PersistentValue();
- }
- v8::Handle<v8::Value> result = script->Run(scopeobject);
- if (tc.HasCaught()) {
+ try {
+ v8::Handle<v8::Value> result = script->Run(scopeobject);
+ if (qmlscope)
+ *qmlscope = scopeobject->v4Value();
+ return result->v4Value();
+ } catch (QV4::Exception &e) {
+ e.accept(ctx);
QQmlError error;
- error.setDescription(QLatin1String("Exception occurred during function evaluation"));
- error.setLine(line);
- error.setUrl(QUrl::fromLocalFile(filename));
- v8::Handle<v8::Message> message = tc.Message();
- if (!message.IsEmpty())
- QQmlExpressionPrivate::exceptionToError(message, error);
+ QQmlExpressionPrivate::exceptionToError(e, error);
+ if (error.description().isEmpty())
+ error.setDescription(QLatin1String("Exception occurred during function evaluation"));
+ if (error.line() == -1)
+ error.setLine(line);
+ if (error.url().isEmpty())
+ error.setUrl(QUrl::fromLocalFile(filename));
ep->warning(error);
- return QV4::PersistentValue();
}
- if (qmlscope)
- *qmlscope = scopeobject->v4Value();
- return result->v4Value();
+ return QV4::PersistentValue();
}
void QQmlJavaScriptExpression::clearGuards()