Add a monitor for the orphan nodes

- Allow the user to keep track of the nodes that might leak
- Possible fix for #27103
This commit is contained in:
Daw11
2019-04-17 22:46:21 +02:00
parent 6697fd9a05
commit 04d0371648
5 changed files with 49 additions and 27 deletions

View File

@@ -41,6 +41,8 @@
VARIANT_ENUM_CAST(Node::PauseMode);
int Node::orphan_node_count = 0;
void Node::_notification(int p_notification) {
switch (p_notification) {
@@ -84,11 +86,14 @@ void Node::_notification(int p_notification) {
add_to_group("_vp_unhandled_key_input" + itos(get_viewport()->get_instance_id()));
get_tree()->node_count++;
orphan_node_count--;
} break;
case NOTIFICATION_EXIT_TREE: {
get_tree()->node_count--;
orphan_node_count++;
if (data.input)
remove_from_group("_vp_input" + itos(get_viewport()->get_instance_id()));
if (data.unhandled_input)
@@ -2938,6 +2943,8 @@ Node::Node() {
data.use_placeholder = false;
data.display_folded = false;
data.ready_first = true;
orphan_node_count++;
}
Node::~Node() {
@@ -2948,6 +2955,8 @@ Node::~Node() {
ERR_FAIL_COND(data.parent);
ERR_FAIL_COND(data.children.size());
orphan_node_count--;
}
////////////////////////////////