Skip to content

Add is_exiting to the EditorInterface #107861

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Naros
Copy link
Contributor

@Naros Naros commented Jun 22, 2025

There are some corner cases where an EditorPlugin may need to know whether the editor is currently in an exit sequence, and to perform some different behavior in this case. There is currently no reliable way to infer that state without resorting to scene node hacks to check for various things such as "is editor base control dimmed".

@Naros Naros requested a review from a team as a code owner June 22, 2025 16:18
@ydeltastar
Copy link
Contributor

What is the difference from using _exit_tree() in the EditorPlugin?

@Naros
Copy link
Contributor Author

Naros commented Jun 22, 2025

@ydeltastar here's an example of what a real GDExtension plugin may implement, using ScriptEditor as an example:

void ScriptEditorPlugin::save_external_data() {
	if (!EditorNode::get_singleton()->is_exiting()) {
		script_editor->save_all_scripts();
	}
}

Right now this requires silly hacks like this:

    const bool editor_exiting = EditorInterface::get_singleton()->get_base_control()->get_modulate() != Color(1, 1, 1, 1);
    if (!editor_exiting && _editor_panel)
        _editor_panel->save_all_resources();

If how Editor dimming changes in the future, that logic breaks and becomes brittle. A reliable and consistent way should be provided so that the same sort of behavior can be achieved in GDExtension.

I think relying on _exit_tree may work in some circumstances, but it would not here because the editor calls back into the _save_external_data before the EditorPlugin is removed from the scene tree.

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.

3 participants