Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
czogran opened this issue Feb 26, 2024 · 0 comments
Open

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

czogran opened this issue Feb 26, 2024 · 0 comments

Comments

@czogran
Copy link

czogran commented Feb 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant