aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-07-12 20:47:41 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-07-17 13:09:50 +0200
commit140634d2029bfcffd77b16175906082bd03d2d0c (patch)
tree1803d693e778dfcd50b10720a2f57b2bbb3da71a /src/qml/qml/qqmltypeloader.cpp
parentd2c6ac8d5eaa1d4b53b647f01c53d821bbba4665 (diff)
Add support for implicit module imports
This allows a module to make another module import with the same minor version and in the same qualified namespace. This will be used to make import QtQuick 2.5 implicitly import QtQml 2.5, to maintain compatibility. It used to be implemented by means of calling C++ type registration functions directly. Change-Id: I64c7bfe25d75b9a45f5d44a10d035fc2f86d30ca Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader.cpp')
-rw-r--r--src/qml/qml/qqmltypeloader.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index a1bf9e9201..3a18bbf7c9 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -517,6 +517,9 @@ bool QQmlTypeLoader::Blob::updateQmldir(const QQmlRefPointer<QQmlQmldirData> &da
if (!m_importCache.updateQmldirContent(typeLoader()->importDatabase(), import->uri, import->qualifier, qmldirIdentifier, qmldirUrl, errors))
return false;
+ if (!loadImportDependencies(import, qmldirIdentifier, errors))
+ return false;
+
import->priority = data->priority(this);
// Release this reference at destruction
@@ -573,6 +576,9 @@ bool QQmlTypeLoader::Blob::addImport(QQmlTypeLoader::Blob::PendingImportPtr impo
import->minorVersion, qmldirFilePath, qmldirUrl, false, errors))
return false;
+ if (!loadImportDependencies(import, qmldirFilePath, errors))
+ return false;
+
if (!import->qualifier.isEmpty()) {
// Does this library contain any qualified scripts?
QUrl libraryUrl(qmldirUrl);
@@ -677,6 +683,21 @@ void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob)
}
}
+bool QQmlTypeLoader::Blob::loadImportDependencies(PendingImportPtr currentImport, const QString &qmldirUri, QList<QQmlError> *errors)
+{
+ const QQmlTypeLoaderQmldirContent qmldir = typeLoader()->qmldirContent(qmldirUri);
+ for (const QString &implicitImports: qmldir.imports()) {
+ auto dependencyImport = std::make_shared<PendingImport>();
+ dependencyImport->uri = implicitImports;
+ dependencyImport->qualifier = currentImport->qualifier;
+ dependencyImport->majorVersion = currentImport->majorVersion;
+ dependencyImport->minorVersion = currentImport->minorVersion;
+ if (!addImport(dependencyImport, errors))
+ return false;
+ }
+ return true;
+}
+
bool QQmlTypeLoader::Blob::isDebugging() const
{
return typeLoader()->engine()->handle()->debugger() != nullptr;