Ensure node's area tree signals are disconnected when clearing monitoring,

even if nodes are no longer in the tree.
This commit is contained in:
Marcel Admiraal 2020-08-23 11:09:27 +01:00
parent 504f47eaec
commit e2d0dfe3c7
1 changed files with 6 additions and 8 deletions

View File

@ -207,7 +207,9 @@ void Area::_clear_monitoring() {
if (!node) { //node may have been deleted in previous frame or at other legiminate point if (!node) { //node may have been deleted in previous frame or at other legiminate point
continue; continue;
} }
//ERR_CONTINUE(!node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
if (!E->get().in_tree) { if (!E->get().in_tree) {
continue; continue;
@ -218,9 +220,6 @@ void Area::_clear_monitoring() {
} }
emit_signal(SceneStringNames::get_singleton()->body_exited, node); emit_signal(SceneStringNames::get_singleton()->body_exited, node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_body_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_body_exit_tree);
} }
} }
@ -236,7 +235,9 @@ void Area::_clear_monitoring() {
if (!node) { //node may have been deleted in previous frame or at other legiminate point if (!node) { //node may have been deleted in previous frame or at other legiminate point
continue; continue;
} }
//ERR_CONTINUE(!node);
node->disconnect(SceneStringNames::get_singleton()->tree_entered, this, SceneStringNames::get_singleton()->_area_enter_tree);
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
if (!E->get().in_tree) { if (!E->get().in_tree) {
continue; continue;
@ -247,9 +248,6 @@ void Area::_clear_monitoring() {
} }
emit_signal(SceneStringNames::get_singleton()->area_exited, obj); 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_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree);
} }
} }
} }