diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index cf94a3f03e3..0ad6a126358 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -188,7 +188,7 @@ void TextEditorActionHandlerPrivate::createActions() registerAction(SELECTALL, [] (TextEditorWidget *w) { w->selectAll(); }, true); registerAction(GOTO, [](TextEditorWidget *) { - LocatorManager::showFilter(TextEditorPlugin::lineNumberFilter()); + LocatorManager::showFilter(lineNumberFilter()); }); m_modifyingActions << registerAction(PRINT, [](TextEditorWidget *widget) { widget->print(ICore::printer()); diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index 3091bdd17be..b6981823a55 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -16,7 +16,6 @@ #include "markdowneditor.h" #include "outlinefactory.h" #include "plaintexteditorfactory.h" -#include "snippets/snippet.h" #include "snippets/snippetprovider.h" #include "tabsettings.h" #include "textdocument.h" @@ -43,6 +42,7 @@ #include #include +#include #include #include @@ -263,22 +263,35 @@ void TextEditorPluginPrivate::requestContextMenu(TextEditorWidget *widget, menu->addAction(&m_editBookmarkAction); } -static TextEditorPlugin *m_instance = nullptr; +static class TextEditorPlugin *m_instance = nullptr; -TextEditorPlugin::TextEditorPlugin() +class TextEditorPlugin final : public ExtensionSystem::IPlugin { - QTC_ASSERT(!m_instance, return); - m_instance = this; -} + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TextEditor.json") -TextEditorPlugin::~TextEditorPlugin() -{ - delete d; - d = nullptr; - m_instance = nullptr; -} +public: + TextEditorPlugin() + { + m_instance = this; + } -TextEditorPlugin *TextEditorPlugin::instance() + ~TextEditorPlugin() final + { + delete d; + d = nullptr; + m_instance = nullptr; + } + + ShutdownFlag aboutToShutdown() final; + + void initialize() final; + void extensionsInitialized() final; + + TextEditorPluginPrivate *d = nullptr; +}; + +QObject *pluginInstance() { return m_instance; } @@ -439,7 +452,7 @@ void TextEditorPlugin::extensionsInitialized() }); } -LineNumberFilter *TextEditorPlugin::lineNumberFilter() +LineNumberFilter *lineNumberFilter() { return &m_instance->d->lineNumberFilter; } @@ -532,3 +545,5 @@ void TextEditorPluginPrivate::createStandardContextMenu() } } // namespace TextEditor::Internal + +#include "texteditorplugin.moc" diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h index 1df73dcea9d..35376c3b584 100644 --- a/src/plugins/texteditor/texteditorplugin.h +++ b/src/plugins/texteditor/texteditorplugin.h @@ -3,33 +3,13 @@ #pragma once -#include +#include -namespace TextEditor { -namespace Internal { +namespace TextEditor::Internal { class LineNumberFilter; +LineNumberFilter *lineNumberFilter(); -class TextEditorPlugin final : public ExtensionSystem::IPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "TextEditor.json") +QObject *pluginInstance(); -public: - TextEditorPlugin(); - ~TextEditorPlugin() final; - - static TextEditorPlugin *instance(); - static LineNumberFilter *lineNumberFilter(); - - ShutdownFlag aboutToShutdown() override; - -private: - void initialize() final; - void extensionsInitialized() final; - - class TextEditorPluginPrivate *d = nullptr; -}; - -} // namespace Internal -} // namespace TextEditor +} // TextEditor::Internal diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index b817541b019..2dd9deefd53 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -493,7 +493,7 @@ bool TextMarkRegistry::remove(TextMark *mark) TextMarkRegistry *TextMarkRegistry::instance() { if (!m_instance) - m_instance = new TextMarkRegistry(TextEditorPlugin::instance()); + m_instance = new TextMarkRegistry(pluginInstance()); return m_instance; }