From 18ca16cb2582a080fcc72daf44ddcf7f6ffdb7a0 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Mon, 21 Oct 2024 08:54:07 +0200 Subject: [PATCH] QmlDesigner: Fallback to application Qt If the kit has no Qt it would return an empty path. That leads to errors later. In that case the application Qt is used. Change-Id: Ie5e755bb1f1ada80ea0e565756689a4acc3499fe Reviewed-by: Thomas Hartmann --- .../qmldesigner/qmldesignerprojectmanager.cpp | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp index 9c04f9b1bd3..3ca5e479a05 100644 --- a/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp +++ b/src/plugins/qmldesigner/qmldesignerprojectmanager.cpp @@ -354,26 +354,13 @@ void QmlDesignerProjectManager::editorsClosed(const QList<::Core::IEditor *> &) namespace { -QtSupport::QtVersion *getQtVersion(::ProjectExplorer::Target *target) -{ - if (target) - return QtSupport::QtKitAspect::qtVersion(target->kit()); - - return {}; -} - -[[maybe_unused]] QtSupport::QtVersion *getQtVersion(::ProjectExplorer::Project *project) -{ - return getQtVersion(project->activeTarget()); -} - -Utils::FilePath qmlPath(::ProjectExplorer::Target *target) +QString qmlPath(::ProjectExplorer::Target *target) { auto qt = QtSupport::QtKitAspect::qtVersion(target->kit()); if (qt) - return qt->qmlPath(); + return qt->qmlPath().path(); - return {}; + return QLibraryInfo::path(QLibraryInfo::QmlImportsPath); } [[maybe_unused]] void projectQmldirPaths(::ProjectExplorer::Target *target, QStringList &qmldirPaths) @@ -388,7 +375,7 @@ Utils::FilePath qmlPath(::ProjectExplorer::Target *target) [[maybe_unused]] void qtQmldirPaths(::ProjectExplorer::Target *target, QStringList &qmldirPaths) { if constexpr (useProjectStorage()) { - auto qmlRootPath = qmlPath(target).toString(); + auto qmlRootPath = qmlPath(target); qmldirPaths.push_back(qmlRootPath + "/QtQml"); qmldirPaths.push_back(qmlRootPath + "/QtQuick"); qmldirPaths.push_back(qmlRootPath + "/QtQuick3D"); @@ -443,7 +430,7 @@ Utils::FilePath qmlPath(::ProjectExplorer::Target *target) QStringList qmldirPaths; qmldirPaths.reserve(2); - const QString qmlRootPath = qmlPath(target).toString(); + const QString qmlRootPath = qmlPath(target); qmldirPaths.append(qmlRootPath + "/builtins.qmltypes"); qmldirPaths.append(qmlRootPath + "/jsroot.qmltypes");