aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvme.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-09-29 21:20:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-30 18:21:26 +0200
commitc48d727e25f0a07d709a81765af6196bc0ddb4c5 (patch)
tree1ad34d61bf20e8756d52f44fd17956844a793d84 /src/qml/qml/qqmlvme.cpp
parent2b6dfcf23b8e9d672dff0a083ed4e7adc28115eb (diff)
Compile imported scripts in the loader thread
This has the benefit of blocking the GUI thread less and speeding up type creation in the GUI thread (for types that import js libraries). This patch also brings one behavioral change: Due to the parsing at type instantiation type, things like syntax errors for script imports would only generate a run-time warning and the code in the QML file would just see "undefined". Errors in the script now generate real errors at component compilation time, meaning the errors come out earlier and as real errors. This patch implements the separation for the VME only (to keep the size of this patch small). Change-Id: I82f7f3a2d3d4524ea12a7ab62abd8640aba6a47f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlvme.cpp')
-rw-r--r--src/qml/qml/qqmlvme.cpp32
1 files changed, 3 insertions, 29 deletions
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index f256f3a1ce..5bf679d7a3 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -1088,18 +1088,7 @@ void QQmlScriptData::initialize(QQmlEngine *engine)
QV8Engine *v8engine = ep->v8engine();
QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8engine);
- // 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, QV4::ObjectRef::null(), m_programSource, urlString, 1);
- try {
- program->parse();
- } catch (QV4::Exception &) {
- delete program;
- throw;
- }
-
- m_program = program;
- m_programSource.clear(); // We don't need this anymore
+ m_program = new QV4::Script(v4, QV4::ObjectRef::null(), m_precompiledScript);
addToEngine(engine);
@@ -1119,11 +1108,6 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s
QV4::ExecutionEngine *v4 = QV8Engine::getV4(parentCtxt->engine);
QV4::Scope scope(v4);
- if (script->hasError()) {
- ep->warning(script->error());
- return rv;
- }
-
bool shared = script->pragmas & QQmlScript::Object::ScriptBlock::Shared;
QQmlContextData *effectiveCtxt = parentCtxt;
@@ -1164,18 +1148,8 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s
ctxt->importedScripts << run(ctxt, script->scripts.at(ii)->scriptData());
}
- 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->isInitialized())
+ script->initialize(parentCtxt->engine);
if (!script->m_program) {
if (shared)