From 4e9d3b044e996f45909797ba3a3a88b22967d62e Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Tue, 15 Jul 2014 10:48:36 +0200 Subject: CppTools: Fix Switch Header/Source going to wrong file Check only other projects if the current file is not part of any project. Task-number: QTCREATORBUG-12328 Change-Id: I7db65b26313a26773bbbf17e966abd668ea9a1a5 Reviewed-by: Erik Verbruggen --- src/plugins/cpptools/cpptoolsplugin.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp') diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index 44179a1fb4..d3cb9514eb 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -411,19 +411,20 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader) currentProject); if (!path.isEmpty()) return path; - } // Find files in other projects - CppModelManager *modelManager = CppModelManager::instance(); - QList projectInfos = modelManager->projectInfos(); - foreach (const CppModelManagerInterface::ProjectInfo &projectInfo, projectInfos) { - const ProjectExplorer::Project *project = projectInfo.project().data(); - if (project == currentProject) - continue; // We have already checked the current project. - - const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project); - if (!path.isEmpty()) - return path; + } else { + CppModelManager *modelManager = CppModelManager::instance(); + QList projectInfos = modelManager->projectInfos(); + foreach (const CppModelManagerInterface::ProjectInfo &projectInfo, projectInfos) { + const ProjectExplorer::Project *project = projectInfo.project().data(); + if (project == currentProject) + continue; // We have already checked the current project. + + const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project); + if (!path.isEmpty()) + return path; + } } return QString(); -- cgit v1.2.1