Explorar o código

Fix "Some nodes are referenced by animation tracks" when deleting instance

Haoyu Qiu %!s(int64=2) %!d(string=hai) anos
pai
achega
b50d0ebb28
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      editor/scene_tree_dock.cpp

+ 10 - 0
editor/scene_tree_dock.cpp

@@ -1546,6 +1546,14 @@ void SceneTreeDock::_fill_path_renames(Vector<StringName> base_path, Vector<Stri
 }
 
 bool SceneTreeDock::_has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delete) const {
+	// Skip if this node will be deleted.
+	for (const Node *F : p_to_delete) {
+		if (F == p_node || F->is_ancestor_of(p_node)) {
+			return false;
+		}
+	}
+
+	// This is an AnimationPlayer that survives the deletion.
 	AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
 	if (ap) {
 		Node *root = ap->get_node(ap->get_root());
@@ -1574,11 +1582,13 @@ bool SceneTreeDock::_has_tracks_to_delete(Node *p_node, List<Node *> &p_to_delet
 		}
 	}
 
+	// Recursively check child nodes.
 	for (int i = 0; i < p_node->get_child_count(); i++) {
 		if (_has_tracks_to_delete(p_node->get_child(i), p_to_delete)) {
 			return true;
 		}
 	}
+
 	return false;
 }