diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-06-12 17:03:01 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2013-06-13 08:51:52 +0200 |
commit | ebc31ca3c4a6a49c274f82af52a2e1b6cace30b7 (patch) | |
tree | 5e80ad3dacc2aad47289d577994a58e875dce3d7 /src/qml/qml/qqmlvme.cpp | |
parent | b8f92eef13b30a6ddf3a6e5dbf1a89b5e24cfdc7 (diff) |
Fix syntax error propagation
For syntax errors we use the DiagnosticMessage type in qv4context.cpp,
that contains detailed information about the error. We must catch that
error correctly in QQmlVME::run and report it to the engine.
Change-Id: I8f53c7db8dbdc6afa72396f3c25537690a6f5841
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlvme.cpp')
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 2e09cf49ac..7ca6f4f44f 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -1071,17 +1071,15 @@ void QQmlScriptData::initialize(QQmlEngine *engine) QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); QV8Engine *v8engine = ep->v8engine(); QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8engine); - QV4::ExecutionContext *ctx = v4->current; // If compilation throws an error, a surrounding catch will record it. // pass 0 as the QML object, we set it later before calling run() QV4::Script *program = new QV4::Script(v4, 0, m_programSource, urlString, 1); try { program->parse(); - } catch (QV4::Exception &e) { - e.accept(ctx); + } catch (QV4::Exception &) { delete program; - return; + throw; } m_program = program; @@ -1148,8 +1146,18 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData()); } - if (!script->isInitialized()) - script->initialize(parentCtxt->engine); + if (!script->isInitialized()) { + QV4::ExecutionContext *ctx = QV8Engine::getV4(parentCtxt->engine)->current; + try { + script->initialize(parentCtxt->engine); + } catch (QV4::Exception &e) { + e.accept(ctx); + QQmlError error; + QQmlExpressionPrivate::exceptionToError(e, error); + if (error.isValid()) + ep->warning(error); + } + } if (!script->m_program) return QV4::PersistentValue(); |