Commit d63e27d8 authored by Nikolai Kosjar's avatar Nikolai Kosjar

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: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 7d31cb0e
......@@ -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();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment