diff --git a/src/plugins/scxmleditor/scxmleditorfactory.cpp b/src/plugins/scxmleditor/scxmleditorfactory.cpp index 9ef8e7250af..5a6f61c9773 100644 --- a/src/plugins/scxmleditor/scxmleditorfactory.cpp +++ b/src/plugins/scxmleditor/scxmleditorfactory.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -15,28 +16,43 @@ #include using namespace ScxmlEditor::Constants; -using namespace ScxmlEditor::Internal; -ScxmlEditorFactory::ScxmlEditorFactory() +namespace ScxmlEditor::Internal { + +class ScxmlEditorFactory final : public QObject, public Core::IEditorFactory { - setId(K_SCXML_EDITOR_ID); - setDisplayName(::Core::Tr::tr(C_SCXMLEDITOR_DISPLAY_NAME)); - addMimeType(Utils::Constants::SCXML_MIMETYPE); +public: + ScxmlEditorFactory(QObject *guard) + : QObject(guard) + { + setId(K_SCXML_EDITOR_ID); + setDisplayName(::Core::Tr::tr(C_SCXMLEDITOR_DISPLAY_NAME)); + addMimeType(Utils::Constants::SCXML_MIMETYPE); - Utils::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml"); + Utils::FileIconProvider::registerIconOverlayForSuffix(":/projectexplorer/images/fileoverlay_scxml.png", "scxml"); - setEditorCreator([this] { - if (!m_editorData) { - m_editorData = new ScxmlEditorData; - QGuiApplication::setOverrideCursor(Qt::WaitCursor); - m_editorData->fullInit(); - QGuiApplication::restoreOverrideCursor(); - } - return m_editorData->createEditor(); - }); + setEditorCreator([this] { + if (!m_editorData) { + m_editorData = new ScxmlEditorData; + QGuiApplication::setOverrideCursor(Qt::WaitCursor); + m_editorData->fullInit(); + QGuiApplication::restoreOverrideCursor(); + } + return m_editorData->createEditor(); + }); + } + ~ScxmlEditorFactory() + { + delete m_editorData; + } + +private: + ScxmlEditorData *m_editorData = nullptr; +}; + +void setupScxmlEditor(QObject *guard) +{ + (void) new ScxmlEditorFactory(guard); } -ScxmlEditorFactory::~ScxmlEditorFactory() -{ - delete m_editorData; -} +} // ScxmlEditorFactory diff --git a/src/plugins/scxmleditor/scxmleditorfactory.h b/src/plugins/scxmleditor/scxmleditorfactory.h index 4074281b8a0..98b1090ccd5 100644 --- a/src/plugins/scxmleditor/scxmleditorfactory.h +++ b/src/plugins/scxmleditor/scxmleditorfactory.h @@ -3,22 +3,10 @@ #pragma once -#include +#include -namespace ScxmlEditor { -namespace Internal { +namespace ScxmlEditor::Internal { -class ScxmlEditorData; +void setupScxmlEditor(QObject *guard); -class ScxmlEditorFactory final : public Core::IEditorFactory -{ -public: - ScxmlEditorFactory(); - ~ScxmlEditorFactory(); - -private: - ScxmlEditorData* m_editorData = nullptr; -}; - -} // namespace Internal -} // namespace ScxmlEditor +} // ScxmlEditor::Internal diff --git a/src/plugins/scxmleditor/scxmleditorplugin.cpp b/src/plugins/scxmleditor/scxmleditorplugin.cpp index 47d76a8c089..743664790bb 100644 --- a/src/plugins/scxmleditor/scxmleditorplugin.cpp +++ b/src/plugins/scxmleditor/scxmleditorplugin.cpp @@ -7,11 +7,9 @@ #include -#include - namespace ScxmlEditor::Internal { -class ScxmlEditorPlugin : public ExtensionSystem::IPlugin +class ScxmlEditorPlugin final : public ExtensionSystem::IPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ScxmlEditor.json") @@ -19,15 +17,13 @@ class ScxmlEditorPlugin : public ExtensionSystem::IPlugin private: void initialize() final { - editorFactory = std::make_unique(); + setupScxmlEditor(this); } void extensionsInitialized() final { Core::DesignMode::setDesignModeIsRequired(); } - - std::unique_ptr editorFactory; }; } // ScxmlEditor::Internal