Skip to content

Commit 6572a7f

Browse files
committed
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.
1 parent e885f4a commit 6572a7f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/core/toolsupport.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <qlist.h>
1010
#include <qlogging.h>
1111
#include <qloggingcategory.h>
12-
#include <qnamespace.h>
12+
#include <qqmlengine.h>
1313
#include <qtenvironmentvariables.h>
1414

1515
#include "logcat.hpp"
@@ -78,16 +78,10 @@ bool QmlToolingSupport::lockTooling() {
7878

7979
QString QmlToolingSupport::getQmllsConfig() {
8080
static auto config = []() {
81-
QList<QString> importPaths;
82-
83-
auto addPaths = [&](const QList<QString>& paths) {
84-
for (const auto& path: paths) {
85-
if (!importPaths.contains(path)) importPaths.append(path);
86-
}
87-
};
88-
89-
addPaths(qEnvironmentVariable("QML_IMPORT_PATH").split(u':', Qt::SkipEmptyParts));
90-
addPaths(qEnvironmentVariable("QML2_IMPORT_PATH").split(u':', Qt::SkipEmptyParts));
81+
// We can't replicate the algorithm used to create the import path list as it can have distro
82+
// specific patches, e.g. nixos.
83+
auto importPaths = QQmlEngine().importPathList();
84+
importPaths.removeIf([](const QString& path) { return path.startsWith("qrc:"); });
9185

9286
auto vfsPath = QsPaths::instance()->shellVfsDir()->path();
9387
auto importPathsStr = importPaths.join(u':');

0 commit comments

Comments
 (0)