Browse Source

Node: Rename `child_exited_tree` to `child_exiting_tree`

The name was confusing as this signal is emitted around the same time as
`tree_exiting` and `NOTIFICATION_EXIT_TREE`, i.e. while the child node is
still in tree.

Fixes #59210.

(cherry picked from commit 3e6de687b8e9f5c24ff78312208eae6195e6ca40)
Rémi Verschelde 3 years ago
parent
commit
0cb897421a
4 changed files with 12 additions and 6 deletions
  1. 8 2
      doc/classes/Node.xml
  2. 2 2
      scene/main/node.cpp
  3. 1 1
      scene/scene_string_names.cpp
  4. 1 1
      scene/scene_string_names.h

+ 8 - 2
doc/classes/Node.xml

@@ -764,12 +764,14 @@
 			<argument index="0" name="node" type="Node" />
 			<argument index="0" name="node" type="Node" />
 			<description>
 			<description>
 				Emitted when a child node enters the scene tree, either because it entered on its own or because this node entered with it.
 				Emitted when a child node enters the scene tree, either because it entered on its own or because this node entered with it.
+				This signal is emitted [i]after[/i] the child node's own [constant NOTIFICATION_ENTER_TREE] and [signal tree_entered].
 			</description>
 			</description>
 		</signal>
 		</signal>
-		<signal name="child_exited_tree">
+		<signal name="child_exiting_tree">
 			<argument index="0" name="node" type="Node" />
 			<argument index="0" name="node" type="Node" />
 			<description>
 			<description>
-				Emitted when a child node exits the scene tree, either because it exited on its own or because this node exited.
+				Emitted when a child node is about to exit the scene tree, either because it is being removed or freed directly, or because this node is exiting the tree.
+				When this signal is received, the child [code]node[/code] is still in the tree and valid. This signal is emitted [i]after[/i] the child node's own [signal tree_exiting] and [constant NOTIFICATION_EXIT_TREE].
 			</description>
 			</description>
 		</signal>
 		</signal>
 		<signal name="ready">
 		<signal name="ready">
@@ -785,6 +787,7 @@
 		<signal name="tree_entered">
 		<signal name="tree_entered">
 			<description>
 			<description>
 				Emitted when the node enters the tree.
 				Emitted when the node enters the tree.
+				This signal is emitted [i]after[/i] the related [constant NOTIFICATION_ENTER_TREE] notification.
 			</description>
 			</description>
 		</signal>
 		</signal>
 		<signal name="tree_exited">
 		<signal name="tree_exited">
@@ -795,15 +798,18 @@
 		<signal name="tree_exiting">
 		<signal name="tree_exiting">
 			<description>
 			<description>
 				Emitted when the node is still active but about to exit the tree. This is the right place for de-initialization (or a "destructor", if you will).
 				Emitted when the node is still active but about to exit the tree. This is the right place for de-initialization (or a "destructor", if you will).
+				This signal is emitted [i]before[/i] the related [constant NOTIFICATION_EXIT_TREE] notification.
 			</description>
 			</description>
 		</signal>
 		</signal>
 	</signals>
 	</signals>
 	<constants>
 	<constants>
 		<constant name="NOTIFICATION_ENTER_TREE" value="10">
 		<constant name="NOTIFICATION_ENTER_TREE" value="10">
 			Notification received when the node enters a [SceneTree].
 			Notification received when the node enters a [SceneTree].
+			This notification is emitted [i]before[/i] the related [signal tree_entered].
 		</constant>
 		</constant>
 		<constant name="NOTIFICATION_EXIT_TREE" value="11">
 		<constant name="NOTIFICATION_EXIT_TREE" value="11">
 			Notification received when the node is about to exit a [SceneTree].
 			Notification received when the node is about to exit a [SceneTree].
+			This notification is emitted [i]after[/i] the related [signal tree_exiting].
 		</constant>
 		</constant>
 		<constant name="NOTIFICATION_MOVED_IN_PARENT" value="12">
 		<constant name="NOTIFICATION_MOVED_IN_PARENT" value="12">
 			Notification received when the node is moved in the parent.
 			Notification received when the node is moved in the parent.

+ 2 - 2
scene/main/node.cpp

@@ -371,7 +371,7 @@ void Node::_propagate_exit_tree() {
 	if (data.parent) {
 	if (data.parent) {
 		Variant c = this;
 		Variant c = this;
 		const Variant *cptr = &c;
 		const Variant *cptr = &c;
-		data.parent->emit_signal(SceneStringNames::get_singleton()->child_exited_tree, &cptr, 1);
+		data.parent->emit_signal(SceneStringNames::get_singleton()->child_exiting_tree, &cptr, 1);
 	}
 	}
 
 
 	// exit groups
 	// exit groups
@@ -3149,7 +3149,7 @@ void Node::_bind_methods() {
 	ADD_SIGNAL(MethodInfo("tree_exiting"));
 	ADD_SIGNAL(MethodInfo("tree_exiting"));
 	ADD_SIGNAL(MethodInfo("tree_exited"));
 	ADD_SIGNAL(MethodInfo("tree_exited"));
 	ADD_SIGNAL(MethodInfo("child_entered_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node")));
 	ADD_SIGNAL(MethodInfo("child_entered_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node")));
-	ADD_SIGNAL(MethodInfo("child_exited_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node")));
+	ADD_SIGNAL(MethodInfo("child_exiting_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node")));
 
 
 	ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode");
 	ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode");
 
 

+ 1 - 1
scene/scene_string_names.cpp

@@ -52,7 +52,7 @@ SceneStringNames::SceneStringNames() {
 	tree_exited = StaticCString::create("tree_exited");
 	tree_exited = StaticCString::create("tree_exited");
 	ready = StaticCString::create("ready");
 	ready = StaticCString::create("ready");
 	child_entered_tree = StaticCString::create("child_entered_tree");
 	child_entered_tree = StaticCString::create("child_entered_tree");
-	child_exited_tree = StaticCString::create("child_exited_tree");
+	child_exiting_tree = StaticCString::create("child_exiting_tree");
 	item_rect_changed = StaticCString::create("item_rect_changed");
 	item_rect_changed = StaticCString::create("item_rect_changed");
 	size_flags_changed = StaticCString::create("size_flags_changed");
 	size_flags_changed = StaticCString::create("size_flags_changed");
 	minimum_size_changed = StaticCString::create("minimum_size_changed");
 	minimum_size_changed = StaticCString::create("minimum_size_changed");

+ 1 - 1
scene/scene_string_names.h

@@ -72,7 +72,7 @@ public:
 	StringName tree_exited;
 	StringName tree_exited;
 	StringName ready;
 	StringName ready;
 	StringName child_entered_tree;
 	StringName child_entered_tree;
-	StringName child_exited_tree;
+	StringName child_exiting_tree;
 	StringName size_flags_changed;
 	StringName size_flags_changed;
 	StringName minimum_size_changed;
 	StringName minimum_size_changed;
 	StringName sleeping_state_changed;
 	StringName sleeping_state_changed;