diff options
author | Daw11 <davidebusterna@gmail.com> | 2019-04-17 22:46:21 +0200 |
---|---|---|
committer | Daw11 <davidebusterna@gmail.com> | 2019-04-17 23:13:16 +0200 |
commit | 04d0371648001c1fbf157156fce7f5e9581e1e02 (patch) | |
tree | 452867d749fedddbb5cc89e297af4ac2d82bcf9a /scene | |
parent | 6697fd9a05859914fc320b4b4321fd9fb6170f71 (diff) |
Add a monitor for the orphan nodes
- Allow the user to keep track of the nodes that might leak
- Possible fix for #27103
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/node.cpp | 9 | ||||
-rw-r--r-- | scene/main/node.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 5f9c187e0b..cddf4db2e8 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -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--; } //////////////////////////////// diff --git a/scene/main/node.h b/scene/main/node.h index b490db37c5..9b9ca06455 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -75,6 +75,8 @@ public: bool operator()(const Node *p_a, const Node *p_b) const { return p_b->data.process_priority == p_a->data.process_priority ? p_b->is_greater_than(p_a) : p_b->data.process_priority > p_a->data.process_priority; } }; + static int orphan_node_count; + private: struct GroupData { |