From ed54a7be3d01b571ccaab4bb7dcf35f4846357f1 Mon Sep 17 00:00:00 2001 From: faisal-alam09 Date: Sun, 28 Aug 2022 01:11:48 +0530 Subject: Added a placeholder tab check before creating a new scene. --- editor/editor_node.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 375aa26de9..ba140c4862 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3702,6 +3702,18 @@ void EditorNode::fix_dependencies(const String &p_for_file) { int EditorNode::new_scene() { int idx = editor_data.add_edited_scene(-1); + // 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++) { + bool unsaved = get_undo_redo()->is_history_unsaved(editor_data.get_scene_history_id(i)); + if (!unsaved && editor_data.get_scene_path(i).is_empty()) { + editor_data.remove_scene(i); + idx--; + } + } + } + idx = MAX(idx, 0); + _scene_tab_changed(idx); editor_data.clear_editor_states(); _update_scene_tabs(); -- cgit v1.2.3