forked from qt-creator/qt-creator
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -145,7 +145,7 @@ protected:
|
||||
|
||||
private:
|
||||
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
||||
|
||||
QMetaObject::Connection m_openFileConnection;
|
||||
};
|
||||
|
||||
} // namespace QmlProjectManager
|
||||
|
Reference in New Issue
Block a user