diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-04-22 11:55:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-22 11:55:15 +0200 |
commit | 201cdd358a7955b81097004d22aed2414eedc41a (patch) | |
tree | 8feab9207fd858a8184925a98dc87b8d00533ad2 /scene | |
parent | 429fc5b62ce1a2069aaf7bf966d3557475c8b474 (diff) | |
parent | 04d0371648001c1fbf157156fce7f5e9581e1e02 (diff) |
Merge pull request #28140 from Daw11/orphan-nodes
Add a monitor for the orphan nodes
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 cbe700c826..0465ffe442 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 { |