From db9ee194fb579d102630b90af2980f5a7480e84f Mon Sep 17 00:00:00 2001 From: Knud Dollereder Date: Thu, 27 Jun 2024 16:40:58 +0200 Subject: [PATCH] QmlProjectManager: Respect import paths when checking the uri When checking if an uri in a qmldir file is valid, the cmake generator did not take the importPaths given in the qmlproject into account. This is now fixed. Change-Id: I403665f0c9c57bd41f644cd7c7e19349820b1824 Reviewed-by: Thomas Hartmann --- .../cmakegen/cmakegenerator.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmlprojectmanager/cmakegen/cmakegenerator.cpp b/src/plugins/qmlprojectmanager/cmakegen/cmakegenerator.cpp index d53588b05ad..4f81763f39b 100644 --- a/src/plugins/qmlprojectmanager/cmakegen/cmakegenerator.cpp +++ b/src/plugins/qmlprojectmanager/cmakegen/cmakegenerator.cpp @@ -224,10 +224,20 @@ bool CMakeGenerator::ignore(const Utils::FilePath &path) const bool CMakeGenerator::checkUri(const QString& uri, const Utils::FilePath &path) const { - Utils::FilePath relative = path.relativeChildPath(m_root->dir); - const QList pathComponents = relative.pathView().split('/', Qt::SkipEmptyParts); - const QStringList uriComponents = uri.split('.', Qt::SkipEmptyParts); + QTC_ASSERT(buildSystem(), return false); + Utils::FilePath relative = path.relativeChildPath(m_root->dir); + QList pathComponents = relative.pathView().split('/', Qt::SkipEmptyParts); + + for (const auto& import : buildSystem()->importPaths()) { + Utils::FilePath importPath = Utils::FilePath::fromUserInput(import); + for (const auto& component : importPath.pathView().split('/', Qt::SkipEmptyParts)) { + if (component == pathComponents.first()) + pathComponents.pop_front(); + } + } + + const QStringList uriComponents = uri.split('.', Qt::SkipEmptyParts); if (pathComponents.size() == uriComponents.size()) { for (qsizetype i=0; i