Renamed tree_exited to tree_exiting. tree_exited is now used for actual out of tree notification.

Updated doc accordingly.
This commit is contained in:
Juan Linietsky 2018-01-12 08:28:39 -03:00
parent baef1e71c7
commit a26e6c8215
16 changed files with 51 additions and 41 deletions

View file

@ -32,8 +32,8 @@
<return type="void">
</return>
<description>
Called when the node leaves the [SceneTree] (e.g. upon freeing, scene changing, or after calling [method remove_child] in a script). If the node has children, its [method _exit_tree] callback will be called last, after all its children have left the tree.
Corresponds to the NOTIFICATION_EXIT_TREE notification in [method Object._notification].
Called when the node is about to leave the [SceneTree] (e.g. upon freeing, scene changing, or after calling [method remove_child] in a script). If the node has children, its [method _exit_tree] callback will be called last, after all its children have left the tree.
Corresponds to the NOTIFICATION_EXIT_TREE notification in [method Object._notification] and signal [signal tree_exiting]. To get notified when the node has already left the active tree, connect to the [signal tree_exited]
</description>
</method>
<method name="_input" qualifiers="virtual">
@ -744,9 +744,14 @@
Emitted when the node enters the tree.
</description>
</signal>
<signal name="tree_exiting">
<description>
Emitted when the node is still active but about to exit the tree. This is the right place for de-initialization.
</description>
</signal>
<signal name="tree_exited">
<description>
Emitted when the node exits the tree.
Emitted after the node exits the tree and is no longer active.
</description>
</signal>
</signals>
@ -755,7 +760,7 @@
Notification received when the node enters a [SceneTree].
</constant>
<constant name="NOTIFICATION_EXIT_TREE" value="11">
Notification received when the node exits a [SceneTree].
Notification received when the node is about to exit a [SceneTree].
</constant>
<constant name="NOTIFICATION_MOVED_IN_PARENT" value="12">
Notification received when the node is moved in the parent.

View file

@ -3119,12 +3119,12 @@ void AnimationKeyEditor::set_animation(const Ref<Animation> &p_anim) {
void AnimationKeyEditor::set_root(Node *p_root) {
if (root)
root->disconnect("tree_exited", this, "_root_removed");
root->disconnect("tree_exiting", this, "_root_removed");
root = p_root;
if (root)
root->connect("tree_exited", this, "_root_removed", make_binds(), CONNECT_ONESHOT);
root->connect("tree_exiting", this, "_root_removed", make_binds(), CONNECT_ONESHOT);
}
Node *AnimationKeyEditor::get_root() const {

View file

@ -829,7 +829,7 @@ void EditorSelection::add_node(Node *p_node) {
}
selection[p_node] = meta;
p_node->connect("tree_exited", this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
p_node->connect("tree_exiting", this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
//emit_signal("selection_changed");
}
@ -847,7 +847,7 @@ void EditorSelection::remove_node(Node *p_node) {
if (meta)
memdelete(meta);
selection.erase(p_node);
p_node->disconnect("tree_exited", this, "_node_removed");
p_node->disconnect("tree_exiting", this, "_node_removed");
//emit_signal("selection_changed");
}
bool EditorSelection::is_selected(Node *p_node) const {

View file

@ -2689,7 +2689,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
if (!p_activate) {
previewing->disconnect("tree_exited", this, "_preview_exited_scene");
previewing->disconnect("tree_exiting", this, "_preview_exited_scene");
previewing = NULL;
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), camera->get_camera()); //restore
if (!preview)
@ -2700,7 +2700,7 @@ void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) {
} else {
previewing = preview;
previewing->connect("tree_exited", this, "_preview_exited_scene");
previewing->connect("tree_exiting", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), preview->get_camera()); //replace
view_menu->hide();
surface->update();
@ -2851,7 +2851,7 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) {
Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]);
if (Object::cast_to<Camera>(pv)) {
previewing = Object::cast_to<Camera>(pv);
previewing->connect("tree_exited", this, "_preview_exited_scene");
previewing->connect("tree_exiting", this, "_preview_exited_scene");
VS::get_singleton()->viewport_attach_camera(viewport->get_viewport_rid(), previewing->get_camera()); //replace
view_menu->hide();
surface->update();

View file

@ -170,7 +170,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
E->get().in_tree = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@ -197,7 +197,7 @@ void Area2D::_body_inout(int p_status, const RID &p_body, int p_instance, int p_
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (E->get().in_tree)
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
}
@ -271,7 +271,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_
E->get().in_tree = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
}
@ -298,7 +298,7 @@ void Area2D::_area_inout(int p_status, const RID &p_area, int p_instance, int p_
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (E->get().in_tree)
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
}
@ -338,7 +338,7 @@ void Area2D::_clear_monitoring() {
//ERR_CONTINUE(!node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (!E->get().in_tree)
continue;
@ -368,7 +368,7 @@ void Area2D::_clear_monitoring() {
//ERR_CONTINUE(!node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (!E->get().in_tree)
continue;

View file

@ -310,7 +310,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
E->get().in_scene = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_scene) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@ -339,7 +339,7 @@ void RigidBody2D::_body_inout(int p_status, ObjectID p_instance, int p_body_shap
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_scene)
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
}

View file

@ -219,7 +219,7 @@ void VisibilityEnabler2D::_find_nodes(Node *p_node) {
if (add) {
p_node->connect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
nodes[p_node] = meta;
_change_node_state(p_node, false);
}
@ -262,7 +262,7 @@ void VisibilityEnabler2D::_notification(int p_what) {
if (!visible)
_change_node_state(E->key(), true);
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed");
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed");
}
nodes.clear();

View file

@ -169,7 +169,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo
E->get().in_tree = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@ -196,7 +196,7 @@ void Area::_body_inout(int p_status, const RID &p_body, int p_instance, int p_bo
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (E->get().in_tree)
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
}
@ -246,7 +246,7 @@ void Area::_clear_monitoring() {
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
}
}
@ -276,7 +276,7 @@ void Area::_clear_monitoring() {
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
}
}
}
@ -366,7 +366,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar
E->get().in_tree = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree, make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_entered, node);
}
@ -393,7 +393,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_area_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->area_exited, obj);
}

View file

@ -318,7 +318,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
E->get().in_tree = node && node->is_inside_tree();
if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree, make_binds(objid));
if (E->get().in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node);
}
@ -345,7 +345,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape,
if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, SceneStringNames::get_singleton()->_body_exit_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (in_tree)
emit_signal(SceneStringNames::get_singleton()->body_exited, obj);
}

View file

@ -170,7 +170,7 @@ void VisibilityEnabler::_find_nodes(Node *p_node) {
if (add) {
p_node->connect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
p_node->connect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed", varray(p_node), CONNECT_ONESHOT);
nodes[p_node] = meta;
_change_node_state(p_node, false);
}
@ -208,7 +208,7 @@ void VisibilityEnabler::_notification(int p_what) {
if (!visible)
_change_node_state(E->key(), true);
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed");
E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed");
}
nodes.clear();
@ -240,7 +240,7 @@ void VisibilityEnabler::_node_removed(Node *p_node) {
if (!visible)
_change_node_state(p_node, true);
p_node->disconnect(SceneStringNames::get_singleton()->tree_exited, this, "_node_removed");
p_node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, "_node_removed");
nodes.erase(p_node);
}

View file

@ -56,7 +56,7 @@ void AnimationCache::_clear_cache() {
while (connected_nodes.size()) {
connected_nodes.front()->get()->disconnect("tree_exited", this, "_node_exit_tree");
connected_nodes.front()->get()->disconnect("tree_exiting", this, "_node_exit_tree");
connected_nodes.erase(connected_nodes.front());
}
path_cache.clear();
@ -181,7 +181,7 @@ void AnimationCache::_update_cache() {
if (!connected_nodes.has(path.node)) {
connected_nodes.insert(path.node);
path.node->connect("tree_exited", this, "_node_exit_tree", Node::make_binds(path.node), CONNECT_ONESHOT);
path.node->connect("tree_exiting", this, "_node_exit_tree", Node::make_binds(path.node), CONNECT_ONESHOT);
}
}

View file

@ -261,8 +261,8 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) {
}
{
if (!child->is_connected("tree_exited", this, "_node_removed"))
child->connect("tree_exited", this, "_node_removed", make_binds(child), CONNECT_ONESHOT);
if (!child->is_connected("tree_exiting", this, "_node_removed"))
child->connect("tree_exiting", this, "_node_removed", make_binds(child), CONNECT_ONESHOT);
}
TrackNodeCacheKey key;

View file

@ -323,14 +323,14 @@ void ScrollBar::_notification(int p_what) {
if (drag_slave) {
drag_slave->connect("gui_input", this, "_drag_slave_input");
drag_slave->connect("tree_exited", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
drag_slave->connect("tree_exiting", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
}
}
if (p_what == NOTIFICATION_EXIT_TREE) {
if (drag_slave) {
drag_slave->disconnect("gui_input", this, "_drag_slave_input");
drag_slave->disconnect("tree_exited", this, "_drag_slave_exit");
drag_slave->disconnect("tree_exiting", this, "_drag_slave_exit");
}
drag_slave = NULL;
@ -655,7 +655,7 @@ void ScrollBar::set_drag_slave(const NodePath &p_path) {
if (drag_slave) {
drag_slave->disconnect("gui_input", this, "_drag_slave_input");
drag_slave->disconnect("tree_exited", this, "_drag_slave_exit");
drag_slave->disconnect("tree_exiting", this, "_drag_slave_exit");
}
}
@ -671,7 +671,7 @@ void ScrollBar::set_drag_slave(const NodePath &p_path) {
if (drag_slave) {
drag_slave->connect("gui_input", this, "_drag_slave_input");
drag_slave->connect("tree_exited", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
drag_slave->connect("tree_exiting", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
}
}
}

View file

@ -275,7 +275,7 @@ void Node::_propagate_exit_tree() {
get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_exit_tree, NULL, 0);
}
emit_signal(SceneStringNames::get_singleton()->tree_exited);
emit_signal(SceneStringNames::get_singleton()->tree_exiting);
notification(NOTIFICATION_EXIT_TREE, true);
if (data.tree)
@ -297,6 +297,8 @@ void Node::_propagate_exit_tree() {
data.ready_notified = false;
data.tree = NULL;
data.depth = -1;
emit_signal(SceneStringNames::get_singleton()->tree_exited);
}
void Node::move_child(Node *p_child, int p_pos) {
@ -2952,6 +2954,7 @@ void Node::_bind_methods() {
ADD_SIGNAL(MethodInfo("renamed"));
ADD_SIGNAL(MethodInfo("tree_entered"));
ADD_SIGNAL(MethodInfo("tree_exiting"));
ADD_SIGNAL(MethodInfo("tree_exited"));
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/process" ),"set_process","is_processing") ;

View file

@ -49,6 +49,7 @@ SceneStringNames::SceneStringNames() {
shader_unshaded = StaticCString::create("shader/unshaded");
shading_mode = StaticCString::create("shader/shading_mode");
tree_entered = StaticCString::create("tree_entered");
tree_exiting = StaticCString::create("tree_exiting");
tree_exited = StaticCString::create("tree_exited");
item_rect_changed = StaticCString::create("item_rect_changed");
size_flags_changed = StaticCString::create("size_flags_changed");

View file

@ -69,6 +69,7 @@ public:
StringName shader_unshaded;
StringName shading_mode;
StringName tree_entered;
StringName tree_exiting;
StringName tree_exited;
StringName size_flags_changed;
StringName minimum_size_changed;