diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 0dad025289470d307017ff6c5bea500dcc89cccc..be6aa86093a9cb2de81657888eb2a2f3bf36b2ae 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -1316,6 +1316,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc) } Editor e; + e.revision = ed->document()->revision(); e.textEditor = textEditor; e.selections = selections; e.ifdefedOutBlocks = blockRanges; @@ -1340,8 +1341,11 @@ void CppModelManager::updateEditorSelections() TextEditor::ITextEditor *textEditor = ed.textEditor; TextEditor::BaseTextEditor *editor = qobject_cast<TextEditor::BaseTextEditor *>(textEditor->widget()); + if (! editor) continue; + else if (editor->document()->revision() != ed.revision) + continue; // outdated editor->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, ed.selections); diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 0cc98d06a8e9f6b2d2cbfd8a4992b5ec478990a2..40a492b27ca73c3abd0bd1cfcffa9eb824b42e16 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -176,6 +176,9 @@ private: mutable QMutex protectSnapshot; struct Editor { + Editor() + : revision(-1) {} + int revision; QPointer<TextEditor::ITextEditor> textEditor; QList<QTextEdit::ExtraSelection> selections; QList<TextEditor::BaseTextEditor::BlockRange> ifdefedOutBlocks;