aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-06-17 14:33:47 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-06-20 08:02:06 +0000
commit1d515e2e0f58fd8ee60bc7f2b9a2b31a38c8ce43 (patch)
tree1ca603eb810683bd5ea372d71e73bb95b1a6fdf1 /src/qml/qml/qqmltypeloader.cpp
parentb9645cc5774a2497b2927b5fdad14c8c09a91fe2 (diff)
Script dependency handling cleanup
The code for setting up CompiledData::m_dependentScripts is independent from the QML type compiler and can be moved into the type loader. This will also allow for re-use when using disk backed compilation units. Change-Id: I56ce5674c50dcca8fda294556a3fd31e073cf24d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 56dc4694e0..0ba0384c60 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2102,7 +2102,27 @@ void QQmlTypeData::done()
}
}
- if (isError()) {
+ if (!isError()) {
+ // Collect imported scripts
+ m_compiledData->dependentScripts.reserve(m_scripts.count());
+ for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
+ const QQmlTypeData::ScriptReference &script = m_scripts.at(scriptIndex);
+
+ QStringRef qualifier(&script.qualifier);
+ QString enclosingNamespace;
+
+ const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.'));
+ if (lastDotIndex != -1) {
+ enclosingNamespace = qualifier.left(lastDotIndex).toString();
+ qualifier = qualifier.mid(lastDotIndex+1);
+ }
+
+ m_compiledData->importCache->add(qualifier.toString(), scriptIndex, enclosingNamespace);
+ QQmlScriptData *scriptData = script.script->scriptData();
+ scriptData->addref();
+ m_compiledData->dependentScripts << scriptData;
+ }
+ } else {
m_compiledData = nullptr;
}