ClangCodeModel: Fix race condition

... between semantic re-highlighting and document visibility update.
Make semanticRehighlight() a no-op if the document is not currently
visible, and call it explicitly on an editor change.

Fixes: QTCREATORBUG-24290
Change-Id: Ife61f61d3fb82e8b283bf93ab77d16517f6c6f9c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2020-07-15 16:11:26 +02:00
parent 52a4a83154
commit b20fa85bc0
2 changed files with 9 additions and 2 deletions

View File

@@ -139,8 +139,13 @@ void ClangEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
void ClangEditorDocumentProcessor::semanticRehighlight()
{
m_semanticHighlighter.updateFormatMapFromFontSettings();
const auto matchesEditor = [this](const Core::IEditor *editor) {
return editor->document()->filePath() == m_document.filePath();
};
if (!Utils::contains(Core::EditorManager::visibleEditors(), matchesEditor))
return;
m_semanticHighlighter.updateFormatMapFromFontSettings();
if (m_projectPart)
requestAnnotationsFromBackend();
}

View File

@@ -155,9 +155,11 @@ void ClangModelManagerSupport::onCurrentEditorChanged(Core::IEditor *editor)
return;
const ::Utils::FilePath filePath = editor->document()->filePath();
if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString()))
if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString())) {
processor->semanticRehighlight();
processor->generateTaskHubIssues();
}
}
void ClangModelManagerSupport::connectTextDocumentToTranslationUnit(TextEditor::TextDocument *textDocument)
{