Преглед изворни кода

Guard agains duplicate calling of _ready when instanced in _enter_tree

Fixes #6005

(cherry picked from commit 184173a9b993c145a2782d9e2488b98221c749e1)
Bojidar Marinov пре 8 година
родитељ
комит
13cdc2a6f5
2 измењених фајлова са 6 додато и 1 уклоњено
  1. 5 1
      scene/main/node.cpp
  2. 1 0
      scene/main/node.h

+ 5 - 1
scene/main/node.cpp

@@ -140,6 +140,7 @@ void Node::_notification(int p_notification) {
 
 void Node::_propagate_ready() {
 
+	data.ready_notified=true;
 	data.blocked++;
 	for (int i=0;i<data.children.size();i++) {
 
@@ -2005,7 +2006,9 @@ void Node::_set_tree(SceneTree *p_tree) {
 
 
 		_propagate_enter_tree();
-		_propagate_ready(); //reverse_notification(NOTIFICATION_READY);
+		if (!data.parent || data.parent->data.ready_notified) { // No parent (root) or parent ready
+			_propagate_ready(); //reverse_notification(NOTIFICATION_READY);
+		}
 
 		tree_changed_b=data.tree;
 
@@ -2284,6 +2287,7 @@ Node::Node() {
 	data.fixed_process=false;
 	data.idle_process=false;
 	data.inside_tree=false;
+	data.ready_notified=false;
 
 	data.owner=NULL;
 	data.OW=NULL;

+ 1 - 0
scene/main/node.h

@@ -85,6 +85,7 @@ private:
 		StringName name;
 		SceneTree *tree;
 		bool inside_tree;
+		bool ready_notified;
 #ifdef TOOLS_ENABLED
 		NodePath import_path; //path used when imported, used by scene editors to keep tracking
 #endif