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

Automatically remove editor plugins when deinitializing GDExtension #1138

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

dsnopek
Copy link
Collaborator

@dsnopek dsnopek commented Jun 13, 2023

Currently, developers need to manually remove editor plugins when their GDExtension is deinitialized, for example:

void uninitialize_summator_types(ModuleInitializationLevel p_level) {
	if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
		EditorPlugins::remove_by_type<MyEditorPlugin>();
	}
}

This isn't ideal, because:

  1. Developers might forget to do this, leading to unexpected behavior in the editor
  2. Developers don't need to manually unregister classes, so this is inconsistent with class registration
  3. There is no EditorPlugins::remove_by_type<T>() in Godot, so this is inconsistent with how Godot modules work

This PR has godot-cpp automatically remove any editor plugins when the GDExtension is being uninitialized.

Since this functionality was added for Godot 4.1, I think it would be good to get this PR in for 4.1 as well, so that developers don't start using a pattern that is unnecessary.

This comes from a suggestion from @Zylann on #1114 (comment)

@dsnopek dsnopek added the enhancement This is an enhancement on the current functionality label Jun 13, 2023
@dsnopek dsnopek added this to the 4.1 milestone Jun 13, 2023
@dsnopek dsnopek requested a review from a team as a code owner June 13, 2023 19:21
@dsnopek dsnopek force-pushed the editor-plugins-deinitialize branch from 10c050a to d28a3cb Compare June 13, 2023 19:24
Copy link
Member

@vnen vnen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at the GDExtension meeting.

@akien-mga akien-mga merged commit 130644c into godotengine:master Jun 19, 2023
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants