From 869b6465b9137d40dea880e63221d39be2edd6d6 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sat, 3 Aug 2024 14:50:43 +0200 Subject: [PATCH] Unregister BT instance with debugger if BTPlayer is removed from tree --- bt/bt_player.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index e9d673d..5e433f7 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -80,7 +80,7 @@ void BTPlayer::set_behavior_tree(const Ref &p_tree) { _update_blackboard_plan(); } else { behavior_tree = p_tree; - if (get_owner()) { + if (get_owner() && is_inside_tree()) { _load_tree(); } } @@ -170,6 +170,7 @@ void BTPlayer::_notification(int p_notification) { #ifdef DEBUG_ENABLED if (bt_instance.is_valid()) { bt_instance->set_monitor_performance(monitor_performance); + bt_instance->register_with_debugger(); } #endif // DEBUG_ENABLED } break; @@ -177,6 +178,7 @@ void BTPlayer::_notification(int p_notification) { #ifdef DEBUG_ENABLED if (bt_instance.is_valid()) { bt_instance->set_monitor_performance(false); + bt_instance->unregister_with_debugger(); } #endif // DEBUG_ENABLED