QmlProject: Open connect to ParsingFinished() only once

Task-number: QDS-5018
Change-Id: I2782641c8494c44c71c680e145be7744c98afabc
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Thomas Hartmann
2021-09-07 14:45:32 +02:00
parent 97d6b487ff
commit e543cb0d05
2 changed files with 20 additions and 16 deletions

View File

@@ -144,23 +144,27 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
QTimer::singleShot(0, this, lambda);
}
} else {
connect(this, &QmlProject::anyParsingFinished, this, [this](Target *target, bool success) {
if (target && success) {
const Utils::FilePath &folder = projectDirectory();
const Utils::FilePaths &uiFiles = files([&](const ProjectExplorer::Node *node) {
return node->filePath().completeSuffix() == "ui.qml"
&& node->filePath().parentDir() == folder;
});
if (!uiFiles.isEmpty()) {
Utils::FilePath currentFile;
if (auto cd = Core::EditorManager::currentDocument())
currentFile = cd->filePath();
m_openFileConnection = connect(
this, &QmlProject::anyParsingFinished, this, [this](Target *target, bool success) {
if (m_openFileConnection)
disconnect(m_openFileConnection);
if (currentFile.isEmpty() || !isKnownFile(currentFile))
Core::EditorManager::openEditor(uiFiles.first(), Utils::Id());
if (target && success) {
const Utils::FilePath &folder = projectDirectory();
const Utils::FilePaths &uiFiles = files([&](const ProjectExplorer::Node *node) {
return node->filePath().completeSuffix() == "ui.qml"
&& node->filePath().parentDir() == folder;
});
if (!uiFiles.isEmpty()) {
Utils::FilePath currentFile;
if (auto cd = Core::EditorManager::currentDocument())
currentFile = cd->filePath();
if (currentFile.isEmpty() || !isKnownFile(currentFile))
Core::EditorManager::openEditor(uiFiles.first(), Utils::Id());
}
}
}
});
});
}
}

View File

@@ -145,7 +145,7 @@ protected:
private:
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
QMetaObject::Connection m_openFileConnection;
};
} // namespace QmlProjectManager