diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-12 10:39:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 10:39:54 +0200 |
commit | f586e06f7b7b1066bc234198a6c11123927cb87c (patch) | |
tree | ea9684d5549f9fc9439ffaf438373f5ca5608a9a /editor/plugins | |
parent | 2f7edae2b3064714b2e0fe8302366abc658955ce (diff) | |
parent | 4bf99f4af2c4918883c4382ead7de275fae21eea (diff) |
Merge pull request #60166 from bruvzg/narrow_file_access
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 09bff7c00b..906edb006c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1091,10 +1091,12 @@ void ScriptEditor::_file_dialog_action(String p_file) { switch (file_dialog_option) { case FILE_NEW_TEXTFILE: { Error err; - Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err); - if (err) { - EditorNode::get_singleton()->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!")); - break; + { + Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err); + if (err) { + EditorNode::get_singleton()->show_warning(TTR("Error writing TextFile:") + "\n" + p_file, TTR("Error!")); + break; + } } if (EditorFileSystem::get_singleton()) { @@ -2209,13 +2211,15 @@ Error ScriptEditor::_save_text_file(Ref<TextFile> p_text_file, const String &p_p String source = sqscr->get_text(); Error err; - Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err); + { + Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::WRITE, &err); - ERR_FAIL_COND_V_MSG(err, err, "Cannot save text file '" + p_path + "'."); + ERR_FAIL_COND_V_MSG(err, err, "Cannot save text file '" + p_path + "'."); - file->store_string(source); - if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { - return ERR_CANT_CREATE; + file->store_string(source); + if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) { + return ERR_CANT_CREATE; + } } if (ResourceSaver::get_timestamp_on_save()) { |