Fix EditorFolding crash when switching scenes

(cherry picked from commit 3275e8488b)
This commit is contained in:
Thakee Nathees 2020-03-05 16:12:41 +05:30 committed by Rémi Verschelde
parent 4c325c0732
commit 15057c9284
2 changed files with 3 additions and 1 deletions

View file

@ -133,6 +133,8 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
} }
void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) { void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) {
ERR_FAIL_NULL(p_scene);
FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES); FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
if (!file_check->file_exists(p_path)) //This can happen when creating scene from FilesystemDock. It has path, but no file. if (!file_check->file_exists(p_path)) //This can happen when creating scene from FilesystemDock. It has path, but no file.
return; return;

View file

@ -3246,7 +3246,7 @@ void EditorNode::_clear_undo_history() {
void EditorNode::set_current_scene(int p_idx) { void EditorNode::set_current_scene(int p_idx) {
//Save the folding in case the scene gets reloaded. //Save the folding in case the scene gets reloaded.
if (editor_data.get_scene_path(p_idx) != "") if (editor_data.get_scene_path(p_idx) != "" && editor_data.get_edited_scene_root(p_idx))
editor_folding.save_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx)); editor_folding.save_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx));
if (editor_data.check_and_update_scene(p_idx)) { if (editor_data.check_and_update_scene(p_idx)) {