From 741596481900347ef4c69d80efdffe710e79ff6b Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 19 Jan 2017 15:46:40 +0100 Subject: CppTools: Fix choosing project part after project open As long as there are project parts for a source file, always determine the best project part, instead of trying to stick to the previous one. This ensures the best project part at all times and simplifies the code. Change-Id: I25ea3eb43a5a3e6d93688d4b8965f596dc9ae22b Reviewed-by: David Schulz --- src/plugins/cpptools/cppprojectpartchooser.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/plugins/cpptools/cppprojectpartchooser.cpp') diff --git a/src/plugins/cpptools/cppprojectpartchooser.cpp b/src/plugins/cpptools/cppprojectpartchooser.cpp index 470fcfd4ca..a79b44540a 100644 --- a/src/plugins/cpptools/cppprojectpartchooser.cpp +++ b/src/plugins/cpptools/cppprojectpartchooser.cpp @@ -128,12 +128,13 @@ private: bool m_isAmbiguous = false; }; -ProjectPartInfo ProjectPartChooser::choose(const QString &filePath, +ProjectPartInfo ProjectPartChooser::choose( + const QString &filePath, const ProjectPartInfo ¤tProjectPartInfo, const QString &preferredProjectPartId, const ProjectExplorer::Project *activeProject, Language languagePreference, - bool projectHasChanged) const + bool projectsUpdated) const { QTC_CHECK(m_projectPartsForFile); QTC_CHECK(m_projectPartsFromDependenciesForFile); @@ -144,7 +145,8 @@ ProjectPartInfo ProjectPartChooser::choose(const QString &filePath, QList projectParts = m_projectPartsForFile(filePath); if (projectParts.isEmpty()) { - if (projectPart && currentProjectPartInfo.hint == ProjectPartInfo::IsFallbackMatch) + if (!projectsUpdated && projectPart + && currentProjectPartInfo.hint == ProjectPartInfo::IsFallbackMatch) // Avoid re-calculating the expensive dependency table for non-project files. return {projectPart, ProjectPartInfo::IsFallbackMatch}; @@ -162,16 +164,14 @@ ProjectPartInfo ProjectPartChooser::choose(const QString &filePath, projectPart = prioritizer.projectPart(); } } else { - if (projectHasChanged || !projectParts.contains(projectPart)) { - ProjectPartPrioritizer prioritizer(projectParts, - preferredProjectPartId, - activeProject, - languagePreference); - projectPart = prioritizer.projectPart(); - hint = prioritizer.isAmbiguous() - ? ProjectPartInfo::IsAmbiguousMatch - : ProjectPartInfo::NoHint; - } + ProjectPartPrioritizer prioritizer(projectParts, + preferredProjectPartId, + activeProject, + languagePreference); + projectPart = prioritizer.projectPart(); + hint = prioritizer.isAmbiguous() + ? ProjectPartInfo::IsAmbiguousMatch + : ProjectPartInfo::NoHint; } return {projectPart, hint}; -- cgit v1.2.1