From 6572a7f61df30c3b26e324e5af000086612f2c8b Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 18 Jul 2025 00:33:58 -0700 Subject: [PATCH] tooling: derive import paths from QML engine import paths Due to distro patches and default locations, we can't correctly derive it without calling the QQmlEngine function. --- src/core/toolsupport.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/core/toolsupport.cpp b/src/core/toolsupport.cpp index ad193355..afce008b 100644 --- a/src/core/toolsupport.cpp +++ b/src/core/toolsupport.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "logcat.hpp" @@ -78,16 +78,10 @@ bool QmlToolingSupport::lockTooling() { QString QmlToolingSupport::getQmllsConfig() { static auto config = []() { - QList importPaths; - - auto addPaths = [&](const QList& paths) { - for (const auto& path: paths) { - if (!importPaths.contains(path)) importPaths.append(path); - } - }; - - addPaths(qEnvironmentVariable("QML_IMPORT_PATH").split(u':', Qt::SkipEmptyParts)); - addPaths(qEnvironmentVariable("QML2_IMPORT_PATH").split(u':', Qt::SkipEmptyParts)); + // We can't replicate the algorithm used to create the import path list as it can have distro + // specific patches, e.g. nixos. + auto importPaths = QQmlEngine().importPathList(); + importPaths.removeIf([](const QString& path) { return path.startsWith("qrc:"); }); auto vfsPath = QsPaths::instance()->shellVfsDir()->path(); auto importPathsStr = importPaths.join(u':');