From e2d0dfe3c75a898b6926483c7ceba491abecddb3 Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Sun, 23 Aug 2020 11:09:27 +0100 Subject: [PATCH] Ensure node's area tree signals are disconnected when clearing monitoring, even if nodes are no longer in the tree. --- scene/3d/area.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index b06df294958..0a2b65b4884 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -207,7 +207,9 @@ void Area::_clear_monitoring() { if (!node) { //node may have been deleted in previous frame or at other legiminate point 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) { continue; @@ -218,9 +220,6 @@ void Area::_clear_monitoring() { } 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 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) { continue; @@ -247,9 +248,6 @@ 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_exiting, this, SceneStringNames::get_singleton()->_area_exit_tree); } } }