Merge pull request #49819 from nekomatata/fix-process-mode-inherit

This commit is contained in:
Rémi Verschelde 2021-09-17 19:16:19 +02:00 committed by GitHub
commit 583eaa9869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -70,7 +70,9 @@ void Node::_notification(int p_notification) {
if (data.parent) {
data.process_owner = data.parent->data.process_owner;
} else {
data.process_owner = nullptr;
ERR_PRINT("The root node can't be set to Inherit process mode, reverting to Pausable instead.");
data.process_mode = PROCESS_MODE_PAUSABLE;
data.process_owner = this;
}
} else {
data.process_owner = this;
@ -436,18 +438,18 @@ void Node::set_process_mode(ProcessMode p_mode) {
bool prev_can_process = can_process();
bool prev_enabled = _is_enabled();
data.process_mode = p_mode;
if (data.process_mode == PROCESS_MODE_INHERIT) {
if (p_mode == PROCESS_MODE_INHERIT) {
if (data.parent) {
data.process_owner = data.parent->data.owner;
data.process_owner = data.parent->data.process_owner;
} else {
data.process_owner = nullptr;
ERR_FAIL_MSG("The root node can't be set to Inherit process mode.");
}
} else {
data.process_owner = this;
}
data.process_mode = p_mode;
bool next_can_process = can_process();
bool next_enabled = _is_enabled();
@ -702,6 +704,9 @@ bool Node::_can_process(bool p_paused) const {
process_mode = data.process_mode;
}
// The owner can't be set to inherit, must be a bug.
ERR_FAIL_COND_V(process_mode == PROCESS_MODE_INHERIT, false);
if (process_mode == PROCESS_MODE_DISABLED) {
return false;
} else if (process_mode == PROCESS_MODE_ALWAYS) {

View File

@ -1322,6 +1322,7 @@ SceneTree::SceneTree() {
// Create with mainloop.
root = memnew(Window);
root->set_process_mode(Node::PROCESS_MODE_PAUSABLE);
root->set_name("root");
#ifndef _3D_DISABLED
if (!root->get_world_3d().is_valid()) {