forked from qt-creator/qt-creator
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 <tim.jenssen@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
3ca60700ce
commit
77455efafa
@@ -351,12 +351,16 @@ Utils::FilePath DocumentManager::currentProjectDirPath()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(QmlDesignerPlugin::instance(), return {});
|
QTC_ASSERT(QmlDesignerPlugin::instance(), return {});
|
||||||
|
|
||||||
if (!QmlDesignerPlugin::instance()->currentDesignDocument())
|
if (!QmlDesignerPlugin::instance()->currentDesignDocument()) {
|
||||||
|
if (ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject())
|
||||||
|
return project->projectDirectory();
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
|
Utils::FilePath qmlFileName = QmlDesignerPlugin::instance()->currentDesignDocument()->fileName();
|
||||||
|
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::projectForFile(qmlFileName);
|
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::projectForFile(qmlFileName);
|
||||||
|
|
||||||
if (project)
|
if (project)
|
||||||
return project->projectDirectory();
|
return project->projectDirectory();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user