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 <erik.verbruggen@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-07-15 10:48:36 +02:00
parent 359bc13ea0
commit 4e9d3b044e

View File

@@ -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<CppModelManagerInterface::ProjectInfo> 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.
} else {
CppModelManager *modelManager = CppModelManager::instance();
QList<CppModelManagerInterface::ProjectInfo> 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;
const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project);
if (!path.isEmpty())
return path;
}
}
return QString();