From d06c7ad6f04e43581e28f5847b6e3d2c32e492d0 Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Sat, 14 Sep 2024 20:55:34 -0400 Subject: [PATCH] Fix error reopening non existing scene on startup --- editor/editor_node.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 66fd2cf904e..de68234c10f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5249,14 +5249,18 @@ void EditorNode::_load_open_scenes_from_config(Ref p_layout) { PackedStringArray scenes = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "open_scenes"); for (int i = 0; i < scenes.size(); i++) { - load_scene(scenes[i]); + if (FileAccess::exists(scenes[i])) { + load_scene(scenes[i]); + } } if (p_layout->has_section_key(EDITOR_NODE_CONFIG_SECTION, "current_scene")) { String current_scene = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "current_scene"); - int current_scene_idx = scenes.find(current_scene); - if (current_scene_idx >= 0) { - _set_current_scene(current_scene_idx); + for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { + if (editor_data.get_scene_path(i) == current_scene) { + _set_current_scene(i); + break; + } } }