From 8ff42771a49587b239e1e628c464ec251b949b19 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 29 Jul 2018 21:20:41 -0300 Subject: [PATCH] Ensure process notification is received only if really enabled, fixes #7894 (cherry picked from commit 15db793ef277b6d2c3aae5e5a075ba2ece31b27a) --- scene/main/node.cpp | 13 ++++++++++++- scene/main/node.h | 1 + scene/main/scene_tree.cpp | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 17b8238b0dc..a3562de7dab 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -238,7 +238,7 @@ void Node::_propagate_enter_tree() { void Node::_propagate_exit_tree() { - //block while removing children +//block while removing children #ifdef DEBUG_ENABLED @@ -990,6 +990,17 @@ bool Node::can_call_rset(const StringName &p_property, int p_from) const { return false; } +bool Node::can_process_notification(int p_what) const { + switch (p_what) { + case NOTIFICATION_PHYSICS_PROCESS: return data.physics_process; + case NOTIFICATION_PROCESS: return data.idle_process; + case NOTIFICATION_INTERNAL_PROCESS: return data.idle_process_internal; + case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: return data.physics_process_internal; + } + + return true; +} + bool Node::can_process() const { ERR_FAIL_COND_V(!is_inside_tree(), false); diff --git a/scene/main/node.h b/scene/main/node.h index e9e010c9377..d07fb101e4c 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -355,6 +355,7 @@ public: void set_pause_mode(PauseMode p_mode); PauseMode get_pause_mode() const; bool can_process() const; + bool can_process_notification(int p_what) const; void request_ready(); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 12b5a1498df..ab1a4d403be 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -932,6 +932,8 @@ void SceneTree::_notify_group_pause(const StringName &p_group, int p_notificatio if (!n->can_process()) continue; + if (!n->can_process_notification(p_notification)) + continue; n->notification(p_notification); //ERR_FAIL_COND(node_count != g.nodes.size());