Clang: Unregister file with project immediately on project close

Ensure that first the editors unregister with the removed project part,
then unregister the project part.

This makes testing and following the message logs easier.

It also fixes the following race condition:
 * Unload project of opened file
 * Immediately close the editor before a new project part is calculated
 ==> The editor is closed, but the translation unit is not properly
     unregistered.

Change-Id: I618930d221323435ba60ac6c051380bccc9fdaf1
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-09-18 12:19:46 +02:00
parent 27991f2c8f
commit a5674be613
5 changed files with 51 additions and 11 deletions

View File

@@ -94,9 +94,6 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(
connect(&m_builtinProcessor, &CppTools::BuiltinEditorDocumentProcessor::semanticInfoUpdated,
this, &ClangEditorDocumentProcessor::semanticInfoUpdated);
connect(CppTools::CppModelManager::instance(), &CppTools::CppModelManager::projectPartsRemoved,
this, &ClangEditorDocumentProcessor::onProjectPartsRemoved);
m_semanticHighlighter.setHighlightingRunner(
[this]() -> QFuture<TextEditor::HighlightingResult> {
const int firstLine = 1;
@@ -184,6 +181,11 @@ CppTools::ProjectPart::Ptr ClangEditorDocumentProcessor::projectPart() const
return m_projectPart;
}
void ClangEditorDocumentProcessor::clearProjectPart()
{
m_projectPart.clear();
}
void ClangEditorDocumentProcessor::updateCodeWarnings(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
uint documentRevision)
{
@@ -250,12 +252,6 @@ void ClangEditorDocumentProcessor::onParserFinished()
updateProjectPartAndTranslationUnitForEditor();
}
void ClangEditorDocumentProcessor::onProjectPartsRemoved(const QStringList &projectPartIds)
{
if (m_projectPart && projectPartIds.contains(m_projectPart->id()))
m_projectPart.clear();
}
void ClangEditorDocumentProcessor::updateTranslationUnitForEditor(CppTools::ProjectPart &projectPart)
{
QTC_ASSERT(m_modelManagerSupport, return);