diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-12 10:03:53 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-08-12 10:04:33 +0200 |
commit | 61f72d32b4fddc6e87f21d0243d9f0a32ca61987 (patch) | |
tree | b166541b885e33666bc3dffbde937b5dc0e93bc5 /src/qml/jsruntime/qv4include.cpp | |
parent | 430853836f9c17154ef3ee4cac6b03b90ee493a9 (diff) | |
parent | 01c6af3fc940378e8eee41a9fb8273420ef5a7e1 (diff) |
Merge remote-tracking branch 'origin/5.3' into 5.4
Conflicts:
src/qml/jsruntime/qv4include.cpp
src/quick/items/qquickrendercontrol.cpp
src/quick/items/qquickrendercontrol_p.h
src/quickwidgets/qquickwidget.cpp
Change-Id: Ib2dc0051a38cd283a37a7665eb4a76f6f7ec8b15
Diffstat (limited to 'src/qml/jsruntime/qv4include.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4include.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index b9576e1bee..ece0cfa8b3 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -209,20 +209,28 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) result = i->result(); } else { + QScopedPointer<QV4::Script> script; - QFile f(localFile); + if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url)) { + QV4::CompiledData::CompilationUnit *jsUnit = cachedUnit->createCompilationUnit(); + script.reset(new QV4::Script(scope.engine, qmlcontextobject, jsUnit)); + } else { + QFile f(localFile); - if (f.open(QIODevice::ReadOnly)) { - QByteArray data = f.readAll(); - QString code = QString::fromUtf8(data); - QmlIR::Document::removeScriptPragmas(code); + if (f.open(QIODevice::ReadOnly)) { + QByteArray data = f.readAll(); + QString code = QString::fromUtf8(data); + QmlIR::Document::removeScriptPragmas(code); - QV4::Script script(scope.engine, qmlcontextobject, code, url.toString()); + script.reset(new QV4::Script(scope.engine, qmlcontextobject, code, url.toString())); + } + } + if (!script.isNull()) { QV4::ExecutionContext *ctx = scope.engine->currentContext(); - script.parse(); + script->parse(); if (!scope.engine->hasException) - script.run(); + script->run(); if (scope.engine->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); result = resultValue(scope.engine, Exception); |