Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix saving wrong edited scene state when switching scene tabs #83251

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3664,6 +3664,8 @@ void EditorNode::fix_dependencies(const String &p_for_file) {

int EditorNode::new_scene() {
int idx = editor_data.add_edited_scene(-1);
_set_current_scene(idx); // Before trying to remove an empty scene, set the current tab index to the newly added tab index.

// Remove placeholder empty scene.
if (editor_data.get_edited_scene_count() > 1) {
for (int i = 0; i < editor_data.get_edited_scene_count() - 1; i++) {
Expand All @@ -3674,9 +3676,7 @@ int EditorNode::new_scene() {
}
}
}
idx = MAX(idx, 0);

_set_current_scene(idx);
editor_data.clear_editor_states();
scene_tabs->update_scene_tabs();
return idx;
Expand Down Expand Up @@ -3834,6 +3834,12 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b
// If we are, we'll edit it after the restoration is done.
if (!restoring_scenes) {
push_item(new_scene);
} else {
// Initialize history for restored scenes.
ObjectID id = new_scene->get_instance_id();
Rindbee marked this conversation as resolved.
Show resolved Hide resolved
if (id != editor_history.get_current()) {
editor_history.add_object(id);
}
}

// Load the selected nodes.
Expand Down
Loading