diff --git a/src/plugins/modeleditor/actionhandler.cpp b/src/plugins/modeleditor/actionhandler.cpp index 0c60f893759..837914be320 100644 --- a/src/plugins/modeleditor/actionhandler.cpp +++ b/src/plugins/modeleditor/actionhandler.cpp @@ -45,7 +45,7 @@ namespace Internal { class ActionHandler::ActionHandlerPrivate { public: - Core::Context context; + Core::Context context{Constants::MODEL_EDITOR_ID}; QAction *undoAction = nullptr; QAction *redoAction = nullptr; QAction *cutAction = nullptr; @@ -60,11 +60,9 @@ public: QAction *exportSelectedElementsAction = nullptr; }; -ActionHandler::ActionHandler(const Core::Context &context, QObject *parent) - : QObject(parent), - d(new ActionHandlerPrivate) +ActionHandler::ActionHandler() + : d(new ActionHandlerPrivate) { - d->context = context; } ActionHandler::~ActionHandler() diff --git a/src/plugins/modeleditor/actionhandler.h b/src/plugins/modeleditor/actionhandler.h index 5ec858e5356..fcc2665736d 100644 --- a/src/plugins/modeleditor/actionhandler.h +++ b/src/plugins/modeleditor/actionhandler.h @@ -52,7 +52,7 @@ class ActionHandler : class ActionHandlerPrivate; public: - ActionHandler(const Core::Context &context, QObject *parent = nullptr); + ActionHandler(); ~ActionHandler(); public: diff --git a/src/plugins/modeleditor/modeleditor_plugin.cpp b/src/plugins/modeleditor/modeleditor_plugin.cpp index 2b34be2b33c..67756e94642 100644 --- a/src/plugins/modeleditor/modeleditor_plugin.cpp +++ b/src/plugins/modeleditor/modeleditor_plugin.cpp @@ -32,6 +32,7 @@ #include "modelsmanager.h" #include "settingscontroller.h" #include "uicontroller.h" +#include "actionhandler.h" #include "qmt/infrastructure/uid.h" @@ -59,7 +60,8 @@ class ModelEditorPluginPrivate final public: ModelsManager modelsManager; UiController uiController; - ModelEditorFactory modelFactory{&uiController}; + ActionHandler actionHandler; + ModelEditorFactory modelFactory{&uiController, &actionHandler}; SettingsController settingsController; }; @@ -93,10 +95,7 @@ bool ModelEditorPlugin::initialize(const QStringList &arguments, QString *errorS void ModelEditorPlugin::extensionsInitialized() { - // Retrieve objects from the plugin manager's object pool - // In the extensionsInitialized method, a plugin can be sure that all - // plugins that depend on it are completely initialized. - d->modelFactory.extensionsInitialized(); + d->actionHandler.createActions(); d->settingsController.load(Core::ICore::settings()); } diff --git a/src/plugins/modeleditor/modeleditorfactory.cpp b/src/plugins/modeleditor/modeleditorfactory.cpp index 821df721108..f0f3c651ea2 100644 --- a/src/plugins/modeleditor/modeleditorfactory.cpp +++ b/src/plugins/modeleditor/modeleditorfactory.cpp @@ -34,24 +34,12 @@ namespace ModelEditor { namespace Internal { -ModelEditorFactory::ModelEditorFactory(UiController *uiController) +ModelEditorFactory::ModelEditorFactory(UiController *uiController, ActionHandler *actionHandler) { setId(Constants::MODEL_EDITOR_ID); setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::MODEL_EDITOR_DISPLAY_NAME)); addMimeType(Constants::MIME_TYPE_MODEL); - m_uiController = uiController; - m_actionHandler = new ActionHandler(Core::Context(Constants::MODEL_EDITOR_ID), this); - setEditorCreator([this] { return new ModelEditor(m_uiController, m_actionHandler); }); -} - -ModelEditorFactory::~ModelEditorFactory() -{ - delete m_actionHandler; -} - -void ModelEditorFactory::extensionsInitialized() -{ - m_actionHandler->createActions(); + setEditorCreator([uiController, actionHandler] { return new ModelEditor(uiController, actionHandler); }); } } // namespace Internal diff --git a/src/plugins/modeleditor/modeleditorfactory.h b/src/plugins/modeleditor/modeleditorfactory.h index 5ae8ab563d3..1a84500ade9 100644 --- a/src/plugins/modeleditor/modeleditorfactory.h +++ b/src/plugins/modeleditor/modeleditorfactory.h @@ -37,14 +37,7 @@ class UiController; class ModelEditorFactory : public Core::IEditorFactory { public: - explicit ModelEditorFactory(UiController *uiController); - ~ModelEditorFactory(); - - void extensionsInitialized(); - -private: - UiController *m_uiController = nullptr; - ActionHandler *m_actionHandler = nullptr; + ModelEditorFactory(UiController *uiController, ActionHandler *actionHandler); }; } // namespace Internal