Fix error reopening non existing scene on startup

(cherry picked from commit d06c7ad6f0)
This commit is contained in:
Hilderin 2024-09-14 20:55:34 -04:00 committed by Rémi Verschelde
parent 56a1d07421
commit 15129c044e
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 8 additions and 4 deletions

View File

@ -5334,14 +5334,18 @@ void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout) {
PackedStringArray scenes = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "open_scenes"); PackedStringArray scenes = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "open_scenes");
for (int i = 0; i < scenes.size(); i++) { 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")) { 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"); String current_scene = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "current_scene");
int current_scene_idx = scenes.find(current_scene); for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
if (current_scene_idx >= 0) { if (editor_data.get_scene_path(i) == current_scene) {
_set_current_scene(current_scene_idx); _set_current_scene(i);
break;
}
} }
} }