Commit f4cfa822 authored by jkobus's avatar jkobus Committed by Jarek Kobus

Avoid crash on qmljs plugin unload

The unload of qmljs plugin caused qmljs code style settings
to be deleted, while core still had a pointer to them and
used it afterwards. Added unregisterCodeStyle* methods
for symmetry and used them on plugin destruction.

Change-Id: I49f0fc52f3e71d053e6ada604672a4cc3eafa486
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 37ff8f55
......@@ -241,6 +241,11 @@ CppToolsSettings::~CppToolsSettings()
{
ExtensionSystem::PluginManager::removeObject(d->m_completionSettingsPage);
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
textEditorSettings->unregisterCodeStyle(Constants::CPP_SETTINGS_ID);
textEditorSettings->unregisterCodeStylePool(Constants::CPP_SETTINGS_ID);
textEditorSettings->unregisterCodeStyleFactory(Constants::CPP_SETTINGS_ID);
delete d;
m_instance = 0;
......
......@@ -159,6 +159,11 @@ QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent)
QmlJSToolsSettings::~QmlJSToolsSettings()
{
TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance();
textEditorSettings->unregisterCodeStyle(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
textEditorSettings->unregisterCodeStylePool(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
textEditorSettings->unregisterCodeStyleFactory(QmlJSTools::Constants::QML_JS_SETTINGS_ID);
delete m_globalCodeStyle;
m_globalCodeStyle = 0;
}
......
......@@ -411,6 +411,11 @@ void TextEditorSettings::registerCodeStyleFactory(ICodeStylePreferencesFactory *
m_d->m_languageToFactory.insert(factory->languageId(), factory);
}
void TextEditorSettings::unregisterCodeStyleFactory(Core::Id languageId)
{
m_d->m_languageToFactory.remove(languageId);
}
QMap<Core::Id, ICodeStylePreferencesFactory *> TextEditorSettings::codeStyleFactories() const
{
return m_d->m_languageToFactory;
......@@ -441,6 +446,11 @@ void TextEditorSettings::registerCodeStyle(Core::Id languageId, ICodeStylePrefer
m_d->m_languageToCodeStyle.insert(languageId, prefs);
}
void TextEditorSettings::unregisterCodeStyle(Core::Id languageId)
{
m_d->m_languageToCodeStyle.remove(languageId);
}
CodeStylePool *TextEditorSettings::codeStylePool() const
{
return m_d->m_behaviorSettingsPage->codeStylePool();
......@@ -456,6 +466,11 @@ void TextEditorSettings::registerCodeStylePool(Core::Id languageId, CodeStylePoo
m_d->m_languageToCodeStylePool.insert(languageId, pool);
}
void TextEditorSettings::unregisterCodeStylePool(Core::Id languageId)
{
m_d->m_languageToCodeStylePool.remove(languageId);
}
void TextEditorSettings::registerMimeTypeForLanguageId(const QString &mimeType, Core::Id languageId)
{
m_d->m_mimeTypeToLanguage.insert(mimeType, languageId);
......
......@@ -92,15 +92,18 @@ public:
ICodeStylePreferencesFactory *codeStyleFactory(Core::Id languageId) const;
QMap<Core::Id, ICodeStylePreferencesFactory *> codeStyleFactories() const;
void registerCodeStyleFactory(ICodeStylePreferencesFactory *codeStyleFactory);
void unregisterCodeStyleFactory(Core::Id languageId);
CodeStylePool *codeStylePool() const;
CodeStylePool *codeStylePool(Core::Id languageId) const;
void registerCodeStylePool(Core::Id languageId, CodeStylePool *pool);
void unregisterCodeStylePool(Core::Id languageId);
ICodeStylePreferences *codeStyle() const;
ICodeStylePreferences *codeStyle(Core::Id languageId) const;
QMap<Core::Id, ICodeStylePreferences *> codeStyles() const;
void registerCodeStyle(Core::Id languageId, ICodeStylePreferences *prefs);
void unregisterCodeStyle(Core::Id languageId);
void registerMimeTypeForLanguageId(const QString &mimeType, Core::Id languageId);
Core::Id languageId(const QString &mimeType) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment