From aa8094007651a58cf6cc0041a8114694c29729b5 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 6 Mar 2025 17:34:17 +0100 Subject: [PATCH] QmlDesigner: Fix DocumentManager::currentFilePath If no QML file was opened this was not working since we returned too early. This fixes the function in case no QML file was opened. Change-Id: Ie6b8b4becfee4ed05760e31b766d8d0a9b88a666 Reviewed-by: Tim Jenssen (cherry picked from commit 77455efafad6630087ea22a59e198f629ccde9c9) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/qmldesigner/documentmanager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp index 8530743d5fb..a913b5aac0a 100644 --- a/src/plugins/qmldesigner/documentmanager.cpp +++ b/src/plugins/qmldesigner/documentmanager.cpp @@ -351,12 +351,16 @@ Utils::FilePath DocumentManager::currentProjectDirPath() { QTC_ASSERT(QmlDesignerPlugin::instance(), return {}); - if (!QmlDesignerPlugin::instance()->currentDesignDocument()) + if (!QmlDesignerPlugin::instance()->currentDesignDocument()) { + if (ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject()) + return project->projectDirectory(); return {}; + } Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName(); ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::projectForFile(qmlFileName); + if (project) return project->projectDirectory();