forked from qt-creator/qt-creator
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:
@@ -139,8 +139,13 @@ void ClangEditorDocumentProcessor::recalculateSemanticInfoDetached(bool force)
|
|||||||
|
|
||||||
void ClangEditorDocumentProcessor::semanticRehighlight()
|
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)
|
if (m_projectPart)
|
||||||
requestAnnotationsFromBackend();
|
requestAnnotationsFromBackend();
|
||||||
}
|
}
|
||||||
|
@@ -155,8 +155,10 @@ void ClangModelManagerSupport::onCurrentEditorChanged(Core::IEditor *editor)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const ::Utils::FilePath filePath = editor->document()->filePath();
|
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();
|
processor->generateTaskHubIssues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangModelManagerSupport::connectTextDocumentToTranslationUnit(TextEditor::TextDocument *textDocument)
|
void ClangModelManagerSupport::connectTextDocumentToTranslationUnit(TextEditor::TextDocument *textDocument)
|
||||||
|
Reference in New Issue
Block a user