CppTools/Clang: Announce only removed project parts

...and not all projects parts of a project if it is closed.

Re-produce with:
  open a project A with subdirs (e.g. qtcreator.pro)
  open a subdir project from project A (e.g. cppeditor.pro)
  close project A
  --> The project part representing the subdir is announced as removed
      although it is still open.

The clang code model was the only affected user - affected translation
units were not parsed/updated anymore
("ERROR: ProjectPartDoesNotExistMessage").

Change-Id: Ia79341ce201e3b4aefff9f597920dbc6f7d67634
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2016-06-22 11:15:19 +02:00
parent 7d31cb0e18
commit d63e27d877

View File

@@ -996,34 +996,34 @@ void CppModelManager::delayedGC()
d->m_delayedGcTimer.start(500);
}
static QStringList idsOfAllProjectParts(const ProjectInfo &projectInfo)
static QStringList removedProjectParts(const QStringList &before, const QStringList &after)
{
QStringList projectPaths;
foreach (const ProjectPart::Ptr &part, projectInfo.projectParts())
projectPaths << part->id();
return projectPaths;
QSet<QString> b = before.toSet();
b.subtract(after.toSet());
return b.toList();
}
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
{
QStringList projectPartIds;
QStringList idsOfRemovedProjectParts;
d->m_projectToIndexerCanceled.remove(project);
{
QMutexLocker locker(&d->m_projectMutex);
d->m_dirty = true;
// Save paths
const ProjectInfo projectInfo = d->m_projectToProjectsInfo.value(project, ProjectInfo());
projectPartIds = idsOfAllProjectParts(projectInfo);
const QStringList projectPartsIdsBefore = d->m_projectPartIdToProjectProjectPart.keys();
d->m_projectToProjectsInfo.remove(project);
recalculateProjectPartMappings();
const QStringList projectPartsIdsAfter = d->m_projectPartIdToProjectProjectPart.keys();
idsOfRemovedProjectParts = removedProjectParts(projectPartsIdsBefore, projectPartsIdsAfter);
}
if (!projectPartIds.isEmpty())
emit projectPartsRemoved(projectPartIds);
if (!idsOfRemovedProjectParts.isEmpty())
emit projectPartsRemoved(idsOfRemovedProjectParts);
delayedGC();
}