diff options
author | lonesurvivor <musicmylove@gmx.net> | 2017-01-25 20:52:44 +0100 |
---|---|---|
committer | lonesurvivor <musicmylove@gmx.net> | 2017-01-25 20:52:44 +0100 |
commit | 9cddaab4d1811b367c9616d35e28a8c428cf3b3f (patch) | |
tree | f9f587973dca6b5416c74efd048476cdeedddc80 | |
parent | 430f3e6043e806a350c82e054395b48367ecb8a7 (diff) |
When overlappinng Area2Ds are removed with remove_child(), _enter_tree and _exit_tree signals are now properly disconnected upon removal
-rw-r--r-- | scene/2d/area_2d.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index a72e1164b4..96c5bea137 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -357,6 +357,10 @@ void Area2D::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = obj ? obj->cast_to<Node>() : NULL; 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); + if (!E->get().in_tree) continue; @@ -366,9 +370,6 @@ void Area2D::_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); } } @@ -388,6 +389,9 @@ void Area2D::_clear_monitoring() { continue; //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); + if (!E->get().in_tree) continue; @@ -397,9 +401,6 @@ void Area2D::_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); } } |