From 1fc7151909255ae94f7c7f55b7ba019022ac94ac Mon Sep 17 00:00:00 2001
From: Leandro Melo <leandro.melo@nokia.com>
Date: Wed, 18 Aug 2010 15:33:52 +0200
Subject: [PATCH] Generic highlighter: Notify editors when mime type
 registration is done.

Now it is no longer necessary to close the editor for the highlighting to take effect.
---
 src/plugins/texteditor/generichighlighter/manager.cpp | 2 ++
 src/plugins/texteditor/generichighlighter/manager.h   | 3 +++
 src/plugins/texteditor/plaintexteditor.cpp            | 5 +++--
 src/plugins/texteditor/plaintexteditor.h              | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp
index 571fa4065e6..1ab8ced5309 100644
--- a/src/plugins/texteditor/generichighlighter/manager.cpp
+++ b/src/plugins/texteditor/generichighlighter/manager.cpp
@@ -236,6 +236,8 @@ void Manager::registerMimeTypesFinished()
     if (m_queuedMimeTypeRegistrations > 0) {
         --m_queuedMimeTypeRegistrations;
         registerMimeTypes();
+    } else {
+        emit mimeTypesRegistered();
     }
 }
 
diff --git a/src/plugins/texteditor/generichighlighter/manager.h b/src/plugins/texteditor/generichighlighter/manager.h
index eac24665ed2..7729efcad7c 100644
--- a/src/plugins/texteditor/generichighlighter/manager.h
+++ b/src/plugins/texteditor/generichighlighter/manager.h
@@ -88,6 +88,9 @@ private slots:
     void downloadAvailableDefinitionsListFinished();
     void downloadDefinitionsFinished();
 
+signals:
+    void mimeTypesRegistered();
+
 private:
     Manager();
     Q_DISABLE_COPY(Manager)
diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp
index 58441bf02b6..f4092e34006 100644
--- a/src/plugins/texteditor/plaintexteditor.cpp
+++ b/src/plugins/texteditor/plaintexteditor.cpp
@@ -74,7 +74,8 @@ PlainTextEditor::PlainTextEditor(QWidget *parent)
 
     m_commentDefinition.clearCommentStyles();
 
-    connect(file(), SIGNAL(changed()), this, SLOT(fileChanged()));
+    connect(file(), SIGNAL(changed()), this, SLOT(configure()));
+    connect(Manager::instance(), SIGNAL(mimeTypesRegistered()), this, SLOT(configure()));
 }
 
 PlainTextEditor::~PlainTextEditor()
@@ -161,7 +162,7 @@ void PlainTextEditor::setTabSettings(const TextEditor::TabSettings &ts)
     }
 }
 
-void PlainTextEditor::fileChanged()
+void PlainTextEditor::configure()
 {
     configure(Core::ICore::instance()->mimeDatabase()->findByFile(file()->fileName()));
 }
diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h
index fb9436907e5..55fb62ca035 100644
--- a/src/plugins/texteditor/plaintexteditor.h
+++ b/src/plugins/texteditor/plaintexteditor.h
@@ -79,7 +79,7 @@ public slots:
     virtual void setTabSettings(const TextEditor::TabSettings &);
 
 private slots:
-    void fileChanged();
+    void configure();
 
 protected:
     virtual BaseTextEditorEditable *createEditableInterface() { return new PlainTextEditorEditable(this); }    
-- 
GitLab