From 77455efafad6630087ea22a59e198f629ccde9c9 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. Pick-to: qds/4.7 Change-Id: Ie6b8b4becfee4ed05760e31b766d8d0a9b88a666 Reviewed-by: Tim Jenssen --- 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 c650c42713e..3ab5b8d937d 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();