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

"Parent node is busy setting up children" error on focusing out with "Save on Focus Lost" enabled #76459

Closed
trollusk opened this issue Apr 26, 2023 · 6 comments

Comments

@trollusk
Copy link

Godot version

Godot 4.0.2

System information

Windows 11

Issue description

Sprite3D nodes always produce the following red error message:

Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.
scene/main/window.cpp:1459 - Condition "!is_inside_tree()" is true.

This occurs even if the scene contains nothing but the Sprite3D node, and is run in an otherwise empty project.

The error message gives no information about its origin (i.e. which node is producing the error).

Steps to reproduce

Create a new scene containing only a Sprite3D node. Run the scene.

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Apr 26, 2023

I can't reproduce this on 4.0.2.stable or 4.1.dev d6dde81 (Linux) with the following scene setups using the Forward+ or Compatibility rendering methods:

image

image

Please upload a minimal reproduction project to make this easier to troubleshoot.

@trollusk
Copy link
Author

Run the scene in this project:
Test.zip

@Calinou
Copy link
Member

Calinou commented Apr 27, 2023

Run the scene in this project: Test.zip

I've tried that project and still don't get any messages in the Output panel (or terminal) when running the project.

@09silverware
Copy link

This happens on my setup, it is not related to Sprite3D.

  Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.
  scene/main/window.cpp:1459 - Condition "!is_inside_tree()" is true.

4.0.2.stable [7a0977c] via Steam on Windows 10.

This happens when I have Save on Focus Lost enabled in the editor.
I think it's trying to do something with the current focus item when it auto saves.
The save does seem to work fine.

Normal saves are perfectly fine.

Happens even with Overlay Disabled...

@kleonc
Copy link
Member

kleonc commented Apr 28, 2023

This happens when I have Save on Focus Lost enabled in the editor.

Can confirm this is the cause. Specifically it fails to add_child in here:

EditorNode *ed = EditorNode::get_singleton();
if (ed && !is_inside_tree()) {
Window *w = ed->get_window();
while (w && w->get_exclusive_child()) {
w = w->get_exclusive_child();
}
if (w && w != this) {
w->add_child(this);
popup_centered(ms);
}
}

because the Window w seems to be currently propagating the focus out notification (which trigerred the scene saving / creating progress dialog) and hence it's blocking child addition:

godot/scene/main/node.cpp

Lines 1949 to 1957 in 1becfea

void Node::propagate_notification(int p_notification) {
data.blocked++;
notification(p_notification);
for (KeyValue<StringName, Node *> &K : data.children) {
K.value->propagate_notification(p_notification);
}
data.blocked--;
}

case NOTIFICATION_APPLICATION_FOCUS_OUT: {
// Save on focus loss before applying the FPS limit to avoid slowing down the saving process.
if (EDITOR_GET("interface/editor/save_on_focus_loss")) {
_menu_option_confirm(FILE_SAVE_SCENE, false);
}

ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.");

Deferring these seems like the most straighforward thing to do, not sure if that's a proper fix though, might be just a workaround. cc @bruvzg who added this in #71209.

@kleonc kleonc changed the title Sprite3D node always gives "Parent node is busy setting up children" error "Parent node is busy setting up children" error on focusing out with "Save on Focus Lost" enabled Apr 28, 2023
@bruvzg bruvzg self-assigned this Apr 28, 2023
@Calinou
Copy link
Member

Calinou commented Apr 28, 2023

Thanks for the confirmation. This is a duplicate of #73765.

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants