mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 11:03:13 -05:00
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.
This commit is contained in:
parent
6c57928063
commit
41f6a683b6
1 changed files with 1 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue