summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolseditorsupport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cpptools/cpptoolseditorsupport.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolseditorsupport.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp
index 01001fee76..45d970d475 100644
--- a/src/plugins/cpptools/cpptoolseditorsupport.cpp
+++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp
@@ -115,16 +115,10 @@ CppEditorSupport::CppEditorSupport(CppModelManager *modelManager, BaseTextEditor
, m_cachedContentsEditorRevision(-1)
, m_initialized(false)
, m_lastHighlightRevision(0)
- , m_highlightingSupport(modelManager->highlightingSupport(textEditor))
{
connect(m_modelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)),
this, SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr)));
- if (m_highlightingSupport && m_highlightingSupport->requiresSemanticInfo()) {
- connect(this, SIGNAL(semanticInfoUpdated(CppTools::SemanticInfo)),
- this, SLOT(startHighlighting()));
- }
-
m_updateDocumentTimer = new QTimer(this);
m_updateDocumentTimer->setSingleShot(true);
m_updateDocumentTimer->setInterval(m_updateDocumentInterval);
@@ -139,7 +133,8 @@ CppEditorSupport::CppEditorSupport(CppModelManager *modelManager, BaseTextEditor
connect(m_textEditor, SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
connect(this, SIGNAL(diagnosticsChanged()), this, SLOT(onDiagnosticsChanged()));
- updateDocument();
+ connect(m_textEditor->document(), SIGNAL(mimeTypeChanged()),
+ this, SLOT(onMimeTypeChanged()));
}
CppEditorSupport::~CppEditorSupport()
@@ -486,3 +481,19 @@ void CppEditorSupport::recalculateSemanticInfoDetached_helper(QFutureInterface<v
TLDProc tldProc(future);
recalculateSemanticInfoNow(source, true, &tldProc);
}
+
+void CppEditorSupport::onMimeTypeChanged()
+{
+ m_highlighter.cancel();
+ m_highlighter.waitForFinished();
+
+ m_highlightingSupport.reset(m_modelManager->highlightingSupport(m_textEditor));
+
+ disconnect(this, SIGNAL(semanticInfoUpdated(CppTools::SemanticInfo)),
+ this, SLOT(startHighlighting()));
+ if (m_highlightingSupport && m_highlightingSupport->requiresSemanticInfo())
+ connect(this, SIGNAL(semanticInfoUpdated(CppTools::SemanticInfo)),
+ this, SLOT(startHighlighting()));
+
+ updateDocumentNow();
+}