From 8e5ad7be46c21361d435d4d76e7ac09b7ee1e94e Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Tue, 31 May 2022 21:28:04 +0300 Subject: [PATCH] Mark node groups as dirty for every children if parent is moved --- scene/main/node.cpp | 18 +++++++++++++----- scene/main/node.h | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 27f240164cd..6ff04875772 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -384,11 +384,7 @@ void Node::_move_child(Node *p_child, int p_pos, bool p_ignore_end) { for (int i = motion_from; i <= motion_to; i++) { data.children[i]->notification(NOTIFICATION_MOVED_IN_PARENT); } - for (const KeyValue &E : p_child->data.grouped) { - if (E.value.group) { - E.value.group->changed = true; - } - } + p_child->_propagate_groups_dirty(); data.blocked--; } @@ -408,6 +404,18 @@ void Node::raise() { } } +void Node::_propagate_groups_dirty() { + for (const KeyValue &E : data.grouped) { + if (E.value.group) { + E.value.group->changed = true; + } + } + + for (int i = 0; i < data.children.size(); i++) { + data.children[i]->_propagate_groups_dirty(); + } +} + void Node::add_child_notify(Node *p_child) { // to be used when not wanted } diff --git a/scene/main/node.h b/scene/main/node.h index 8de6c1ce694..b4ae9b04139 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -174,6 +174,7 @@ private: void _propagate_after_exit_tree(); void _print_orphan_nodes(); void _propagate_process_owner(Node *p_owner, int p_pause_notification, int p_enabled_notification); + void _propagate_groups_dirty(); Array _get_node_and_resource(const NodePath &p_path); void _duplicate_signals(const Node *p_original, Node *p_copy) const;