From 8c53ff79abf3fc52d10cb7905470ceec69d26e3d Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 14 Jul 2015 23:38:33 +0300 Subject: [PATCH] CppEditor: Delay mime initialization on startup Plugins register their mime types on initialize(). If a plugin *reads* from the mime database on initialize(), and plugins that follow it register new mime types, the next read forces reload of the database, which is expensive. Change-Id: Ifd5f1bfea17faf2be25846d954d66884b6fbb204 Reviewed-by: Nikolai Kosjar Reviewed-by: Eike Ziller --- src/plugins/cppeditor/cppeditorplugin.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 4c552d8eda7..1544c406afd 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -107,18 +107,6 @@ public: | TextEditorActionHandler::FollowSymbolUnderCursor); addHoverHandler(new CppHoverHandler); - - if (!HostOsInfo::isMacHost() && !HostOsInfo::isWindowsHost()) { - FileIconProvider::registerIconOverlayForMimeType( - QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppSource, QLatin1String(":/cppeditor/images/qt_cpp.png"))), - Constants::CPP_SOURCE_MIMETYPE); - FileIconProvider::registerIconOverlayForMimeType( - QIcon(creatorTheme()->imageFile(Theme::IconOverlayCSource, QLatin1String(":/cppeditor/images/qt_c.png"))), - Constants::C_SOURCE_MIMETYPE); - FileIconProvider::registerIconOverlayForMimeType( - QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppHeader, QLatin1String(":/cppeditor/images/qt_h.png"))), - Constants::CPP_HEADER_MIMETYPE); - } } }; @@ -280,6 +268,17 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err void CppEditorPlugin::extensionsInitialized() { + if (!HostOsInfo::isMacHost() && !HostOsInfo::isWindowsHost()) { + FileIconProvider::registerIconOverlayForMimeType( + QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppSource, QLatin1String(":/cppeditor/images/qt_cpp.png"))), + Constants::CPP_SOURCE_MIMETYPE); + FileIconProvider::registerIconOverlayForMimeType( + QIcon(creatorTheme()->imageFile(Theme::IconOverlayCSource, QLatin1String(":/cppeditor/images/qt_c.png"))), + Constants::C_SOURCE_MIMETYPE); + FileIconProvider::registerIconOverlayForMimeType( + QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppHeader, QLatin1String(":/cppeditor/images/qt_h.png"))), + Constants::CPP_HEADER_MIMETYPE); + } } ExtensionSystem::IPlugin::ShutdownFlag CppEditorPlugin::aboutToShutdown()