Merge pull request #92760 from Rindbee/deprecate-replacing_by-signal
Call `EditorNode::set_edited_scene()` manually instead of via the `replacing_by` signal
This commit is contained in:
commit
1fb05cb768
|
@ -3706,12 +3706,15 @@ void EditorNode::_remove_scene(int index, bool p_change_tab) {
|
|||
}
|
||||
|
||||
void EditorNode::set_edited_scene(Node *p_scene) {
|
||||
set_edited_scene_root(p_scene, true);
|
||||
}
|
||||
|
||||
void EditorNode::set_edited_scene_root(Node *p_scene, bool p_auto_add) {
|
||||
Node *old_edited_scene_root = get_editor_data().get_edited_scene_root();
|
||||
if (old_edited_scene_root) {
|
||||
if (old_edited_scene_root->get_parent() == scene_root) {
|
||||
scene_root->remove_child(old_edited_scene_root);
|
||||
}
|
||||
old_edited_scene_root->disconnect(SNAME("replacing_by"), callable_mp(this, &EditorNode::set_edited_scene));
|
||||
ERR_FAIL_COND_MSG(p_scene && p_scene != old_edited_scene_root && p_scene->get_parent(), "Non-null nodes that are set as edited scene should not have a parent node.");
|
||||
|
||||
if (p_auto_add && old_edited_scene_root && old_edited_scene_root->get_parent() == scene_root) {
|
||||
scene_root->remove_child(old_edited_scene_root);
|
||||
}
|
||||
get_editor_data().set_edited_scene_root(p_scene);
|
||||
|
||||
|
@ -3723,11 +3726,8 @@ void EditorNode::set_edited_scene(Node *p_scene) {
|
|||
get_tree()->set_edited_scene_root(p_scene);
|
||||
}
|
||||
|
||||
if (p_scene) {
|
||||
if (p_scene->get_parent() != scene_root) {
|
||||
scene_root->add_child(p_scene, true);
|
||||
}
|
||||
p_scene->connect(SNAME("replacing_by"), callable_mp(this, &EditorNode::set_edited_scene));
|
||||
if (p_auto_add && p_scene) {
|
||||
scene_root->add_child(p_scene, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5967,6 +5967,8 @@ void EditorNode::reload_instances_with_path_in_edited_scenes(const String &p_ins
|
|||
instantiated_node->set_scene_file_path(String());
|
||||
}
|
||||
current_edited_scene = instantiated_node;
|
||||
|
||||
editor_data.set_edited_scene_root(current_edited_scene);
|
||||
}
|
||||
|
||||
// Replace the original node with the instantiated version.
|
||||
|
|
|
@ -783,6 +783,7 @@ public:
|
|||
SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited.
|
||||
|
||||
void set_edited_scene(Node *p_scene);
|
||||
void set_edited_scene_root(Node *p_scene, bool p_auto_add);
|
||||
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
|
||||
|
||||
void fix_dependencies(const String &p_for_file);
|
||||
|
|
|
@ -2992,6 +2992,10 @@ void SceneTreeDock::_replace_node(Node *p_node, Node *p_by_node, bool p_keep_pro
|
|||
to_erase.push_back(oldnode->get_child(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (oldnode == edited_scene) {
|
||||
EditorNode::get_singleton()->set_edited_scene_root(newnode, false);
|
||||
}
|
||||
oldnode->replace_by(newnode, true);
|
||||
|
||||
// Re-apply size of anchored control.
|
||||
|
|
Loading…
Reference in New Issue