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

[Editor] Unload addons before quitting to allow cleanup. #93238

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Jun 16, 2024

Fixes #92727

Adds extra plugin unloading step before deleting scene tree to ensure plugins can use the same code for both unloading and disabling plugin.

Existing documentation suggest freeing stuff, including removing nodes in the _exit_tree, which can't be done if plugin is unloaded during scene tree deletion. While removing nodes manually is not necessary, unloading other resources might be, and it is needed to handle disabling plugins, doing all of it from the _exit_tree probably is more convenient than separate _disable_plugin and resource cleanup.

@MikeSchulze
Copy link

A question, when it is now triggered _disable_plugin at Godot exit than it should also trigger _enable_plugin at Godot editor start right?

@bruvzg
Copy link
Member Author

bruvzg commented Jun 17, 2024

A question, when it is now triggered _disable_plugin at Godot exit than it should also trigger _enable_plugin at Godot editor start right?

It's not triggering _disable_plugin on exit (nor _enable_plugin on start).

  • on start it triggers _enter_tree
  • on exit _exit_tree
  • when plugin enabled from project settings _enter_tree and then _enable_plugin
  • when plugin disabled from project settings _disable_plugin and then _exit_tree

So with this change, all cleanups can go to _exit_tree.

@akien-mga akien-mga merged commit edf2f8c into godotengine:master Jun 18, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@bruvzg
Copy link
Member Author

bruvzg commented Jun 23, 2024

For the reference: this broke custom importer add-ons (fix #93518). Since this is a case, it might affect some other plugin processes as well (I have not found any other issues so far).

@bruvzg bruvzg deleted the ed_unload_addons branch June 23, 2024 18:15
@kitbdev
Copy link
Contributor

kitbdev commented Jun 24, 2024

EditorNode::_exit_editor isn't called when using --import or --quit command line flags, so the problem still exists in that case. Maybe NOTIFICATION_EXIT_TREE would be a better place?

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

Successfully merging this pull request may close these issues.

Unloading plugin results into crash on macOS and Linux at Godot exit
4 participants