From e7114956ac4cccc8327991b72c43edfb897a8b34 Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Tue, 11 Feb 2025 17:26:55 +0100 Subject: [PATCH] qmlls: add build folder as import path Work around QTBUG-132263 where qmlls from 6.8.2 doesn't read the necessary .qrc files, and add the build folder (that contains all the .qrc files) as import path for qmlls to find them. This fixes qmlls not going to definition because of the ignored .qrc files. Task-number: QTBUG-132263 Change-Id: Ia0a8821a46c0cfba1767b0dea5761735ea28af06 Reviewed-by: David Schulz --- src/plugins/qmljseditor/qmllsclientsettings.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmljseditor/qmllsclientsettings.cpp b/src/plugins/qmljseditor/qmllsclientsettings.cpp index 22f6250cec8..88b1b6f5152 100644 --- a/src/plugins/qmljseditor/qmllsclientsettings.cpp +++ b/src/plugins/qmljseditor/qmllsclientsettings.cpp @@ -125,8 +125,11 @@ static CommandLine commandLineForQmlls(Project *project) CommandLine result{executable, {}}; - if (auto *configuration = project->activeBuildConfiguration()) - result.addArgs({"-b", configuration->buildDirectory().path()}); + const QString buildDirectory = project->activeBuildConfiguration() + ? project->activeBuildConfiguration()->buildDirectory().path() + : QString(); + if (!buildDirectory.isEmpty()) + result.addArgs({"-b", buildDirectory}); // qmlls 6.8 and later require the import path if (version >= QVersionNumber(6, 8, 0)) { @@ -139,6 +142,10 @@ static CommandLine commandLineForQmlls(Project *project) if (path.language() == QmlJS::Dialect::Qml) result.addArgs({"-I", path.path().path()}); } + + // work around QTBUG-132263 for qmlls 6.8.2 + if (!buildDirectory.isEmpty()) + result.addArgs({"-I", buildDirectory}); } // qmlls 6.8.1 and later require the documentation path