Forráskód Böngészése

Correctly replace scene root when `must_reload` in `EditorData::check_and_update_scene()`

We need to update the scene root in multiple singletons to ensure that
certain flags are correct. This is what `EditorNode::set_edited_scene()`
does.

Usually we use `replace_by` to complete the replacement of the scene
root. Call `EditorNode::set_edited_scene()` when the `replacing_by`
signal is emitted to set the new scene root. This is suitable when
using a single node to replace, which may be problematic if the
replacing node is a tree. Because during the call to `replace_by()`,
the new node and its child nodes will enter tree during `parent->
add_child(p_node)`, and later emits the `replacing_by` signal.

When the parent scene has to be reloaded because the child scene
changes and switches to the parent scene, there is no need to use
`replace_by()` since the scene's diffs are already saved.
风青山 1 éve
szülő
commit
41f6a683b6
1 módosított fájl, 1 hozzáadás és 2 törlés
  1. 1 2
      editor/editor_data.cpp

+ 1 - 2
editor/editor_data.cpp

@@ -722,8 +722,7 @@ bool EditorData::check_and_update_scene(int p_idx) {
 
 		new_scene->set_scene_file_path(edited_scene[p_idx].root->get_scene_file_path());
 		Node *old_root = edited_scene[p_idx].root;
-		edited_scene.write[p_idx].root = new_scene;
-		old_root->replace_by(new_scene, false, false);
+		EditorNode::get_singleton()->set_edited_scene(new_scene);
 		memdelete(old_root);
 		edited_scene.write[p_idx].selection = new_selection;