diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-24 15:29:02 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-30 10:44:06 +0000 |
commit | 92cfb8283262e6a4f1d5678e7915ccf30493c603 (patch) | |
tree | 4487e1f265222697ecdc1dec605945ba26a0f2ae /src/qml/qml/qqmlimport.cpp | |
parent | a57731b718f6c126e15b887d20cb7a7bb0c94118 (diff) |
QtQml: Key plugins by URI where possible
This allows us to associate different qmldir files for the same module
with one another. Typically there is one qmldir file in the resource
file system and one in the QML import path. We cannot load plugins for
the latter, but usually we have already loaded any plugins we need. Now
we can detect this.
This requires us to construct a proper URI for implicit imports. The
easiest way to do this is to just use the URI from the qmldir if
available.
Modules with versions encoded in their paths and modules with multiple
plugins cannot be resolved by URI only. These continue to be keyed by
path. However, as we do not generate such modules, we will not
automatically get two instances of those, and we won't have to fall back
from one to the other.
Change-Id: Ic79add936d263a8e559fd998fca15a6ae160952e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit bae18ecd340f8a952d1b3be2b309d50e84707c69)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml/qml/qqmlimport.cpp')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 6808de2262..35e64b73d1 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1455,6 +1455,13 @@ QTypeRevision QQmlImportsPrivate::addFileImport( return QTypeRevision(); if (qmldir.hasContent()) { + if (uri == QStringLiteral(".")) { + // If this is an implicit import, prefer the qmldir URI. Unless it doesn't exist. + const QString qmldirUri = qmldir.typeNamespace(); + if (!qmldirUri.isEmpty()) + importUri = qmldirUri; + } + version = importExtension(importUri, version, database, &qmldir, errors); if (!version.isValid()) return QTypeRevision(); @@ -1842,9 +1849,9 @@ QTypeRevision QQmlImportDatabase::lockModule(const QString &uri, const QString & return version; } -bool QQmlImportDatabase::removeDynamicPlugin(const QString &filePath) +bool QQmlImportDatabase::removeDynamicPlugin(const QString &pluginId) { - return QQmlPluginImporter::removePlugin(filePath); + return QQmlPluginImporter::removePlugin(pluginId); } QStringList QQmlImportDatabase::dynamicPlugins() const |