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