From e311a3bf616d7be6e214b169fb858d4c7e1cf0e2 Mon Sep 17 00:00:00 2001 From: Burak Hancerli Date: Wed, 26 Jun 2024 16:09:34 +0200 Subject: [PATCH] QmlProjectManager: Fix main qml file path and duplicate signal connection Task-number: QTCREATORBUG-30685 Change-Id: I3d3a0d1bee85b56e43b8bb2e591aa56528554e06 Reviewed-by: Christian Stenger --- src/plugins/qmlprojectmanager/qmlmainfileaspect.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmlprojectmanager/qmlmainfileaspect.cpp b/src/plugins/qmlprojectmanager/qmlmainfileaspect.cpp index 983b7126336..19f2f194717 100644 --- a/src/plugins/qmlprojectmanager/qmlmainfileaspect.cpp +++ b/src/plugins/qmlprojectmanager/qmlmainfileaspect.cpp @@ -49,6 +49,10 @@ QmlMainFileAspect::QmlMainFileAspect(AspectContainer *container) this, &QmlMainFileAspect::changeCurrentFile); connect(EditorManager::instance(), &EditorManager::currentDocumentStateChanged, this, [this] { changeCurrentFile(); }); + connect(ProjectExplorerPlugin::instance(), + &ProjectExplorerPlugin::fileListChanged, + this, + &QmlMainFileAspect::updateFileComboBox); } QmlMainFileAspect::~QmlMainFileAspect() @@ -63,9 +67,6 @@ void QmlMainFileAspect::addToLayout(Layouting::Layout &parent) m_fileListCombo->setModel(&m_fileListModel); updateFileComboBox(); - - connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::fileListChanged, - this, &QmlMainFileAspect::updateFileComboBox); connect(m_fileListCombo, &QComboBox::activated, this, &QmlMainFileAspect::setMainScript); parent.addItems({Tr::tr("Main QML file:"), m_fileListCombo.data()}); @@ -93,7 +94,7 @@ void QmlMainFileAspect::updateFileComboBox() const FilePath projectDir = m_target->project()->projectDirectory(); if (mainScriptSource() == FileInProjectFile) { - const FilePath mainScriptInFilePath = projectDir.relativeChildPath(mainScript()); + const FilePath mainScriptInFilePath = mainScript().relativePathFrom(projectDir); m_fileListModel.clear(); m_fileListModel.appendRow(new QStandardItem(mainScriptInFilePath.toString())); if (m_fileListCombo)