Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Don't defer `child_entered_tree` in `ScriptEditor`

kit7182d67a59c9
diff --git a/editor/script/script_editor_plugin.cpp b/editor/script/script_editor_plugin.cpp
index 45f9cd38a46..2463a0cfdf5 100644
--- a/editor/script/script_editor_plugin.cpp
+++ b/editor/script/script_editor_plugin.cpp
@@ -2351,14 +2351,10 @@ void DocumentEditorContainer::_connect_to_scene() {
if (!edited_scene) {
return;
}
- _connect_to_scene_recursive(edited_scene, edited_scene);
+ _connect_to_scene_recursive(edited_scene);
}
-void DocumentEditorContainer::_connect_to_scene_recursive(Node *p_current, Node *p_base) {
- if (p_current != p_base && p_current->get_owner() != p_base) {
- return;
- }
-
+void DocumentEditorContainer::_connect_to_scene_recursive(Node *p_current) {
_queue_update_list();
const Callable update_callable = callable_mp(this, &DocumentEditorContainer::_queue_update_list);
if (p_current->is_connected(CoreStringName(script_changed), update_callable)) {
@@ -2366,11 +2362,8 @@ void DocumentEditorContainer::_connect_to_scene_recursive(Node *p_current, Node
}
p_current->connect(CoreStringName(script_changed), update_callable);
p_current->connect(SceneStringName(tree_exited), update_callable);
- p_current->connect(SNAME("child_entered_tree"), callable_mp(this, &DocumentEditorContainer::_connect_to_scene_recursive).bind(p_base), CONNECT_DEFERRED);
-
- for (Node *child : p_current->iterate_children()) {
- _connect_to_scene_recursive(child, p_base);
- }
+ // Use `child_entered_tree` to recursively connect to children.
+ p_current->connect(SNAME("child_entered_tree"), callable_mp(this, &DocumentEditorContainer::_connect_to_scene_recursive));
}
void DocumentEditorContainer::_update_document_list() {
diff --git a/editor/script/script_editor_plugin.h b/editor/script/script_editor_plugin.h
index 72e2f5ad237..3b50a10fe07 100644
--- a/editor/script/script_editor_plugin.h
+++ b/editor/script/script_editor_plugin.h
@@ -383,7 +383,7 @@ class DocumentEditorContainer : public MarginContainer {
void _auto_format_text(ScriptEditorBase *p_seb);
void _connect_to_scene();
- void _connect_to_scene_recursive(Node *p_current, Node *p_base);
+ void _connect_to_scene_recursive(Node *p_current);
void _update_document_list();
void _queue_update_list();