Skip to content

Destroying plugin on reload and close have different life cycle #305

@czogran

Description

@czogran

WHY THIS IMPORTANT

Implementing own shutdown_plugin hook has different possible state of plugin in dependency if plugin was reloaded or closed.
For examples when closing plugin you are able to do any action because _garbage_widgets_and_toolbars was last in life cycle when during reloading remove_widget is called after _garbage_widgets_and_toolbars. So order of execution is disturbed. Hence unexpected errors can be seen when "too much" is destroyed manually in shutdown_plugin (for example clearing references to prevent memory leaks).
For example it is not possible to destroy plugin every references manually in shutdown_plugin, hence GC can't destroy component. In my case it leads to necessity to pass node downward the stream and appropriate passing references to node between components to minimize memory leaks.
image
image

Sequence of RELOAD PLUGIN

PluginManager reload_plugin
PluginManager _reload_plugin_save

PluginManager_save_plugin_settings
PluginManager _unload_plugin_shutdown
PluginManager_shutdown_plugin

PluginHandlerDirect shutdown_plugin
PluginHandler shutdown_plugin
PluginHandlerDirect _shutdown_plugin

PluginHandlerDirect self._plugin.shutdown_plugin -> own hook on shutdown_plugin

PluginHandler emit_shutdown_plugin_completed
PluginHandler _garbage_widgets_and_toolbars

// EXTRA ACTIONS WHICH ARE NOT CALLED WHEN ON CLOSE PLUGIN IS CALLED
PluginHandler remove_widget
PluginHandler _check_close
PluginHandler _emit_close_plugin

Sequence of CLOSE PLUGIN

PluginHandler remove_widget
PluginHandler_check_close
PluginHandler_emit_close_plugin

PluginManager unload_plugin
PluginManager_unload_plugin_shutdown
PluginManager_shutdown_plugin

PluginHandlerDirect shutdown_plugin
PluginHandler shutdown_plugin
PluginHandlerDirect _shutdown_plugin

PluginHandlerDirect self._plugin.shutdown_plugin -> own hook on shutdown_plugin

PluginHandler emit_shutdown_plugin_completed
PluginHandler _garbage_widgets_and_toolbars

When widget is destroyed _garbage_widgets_and_toolbars is last in execution, if not it calls further actions.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions