diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-04-12 10:12:40 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-04-12 10:54:39 +0300 |
commit | 4bf99f4af2c4918883c4382ead7de275fae21eea (patch) | |
tree | e741cea7e9395dcffeaa986f34e19819564356fb /platform/javascript/api | |
parent | 5974e1432ef7941a5e29f8723dec85aa45505963 (diff) |
Narrow FileAccess scope to prevent deadlocks.
Diffstat (limited to 'platform/javascript/api')
-rw-r--r-- | platform/javascript/api/javascript_tools_editor_plugin.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/platform/javascript/api/javascript_tools_editor_plugin.cpp b/platform/javascript/api/javascript_tools_editor_plugin.cpp index 46eec8eda2..31ce71127d 100644 --- a/platform/javascript/api/javascript_tools_editor_plugin.cpp +++ b/platform/javascript/api/javascript_tools_editor_plugin.cpp @@ -81,12 +81,14 @@ void JavaScriptToolsEditorPlugin::_download_zip(Variant p_v) { const String base_path = resource_path.substr(0, resource_path.rfind("/")) + "/"; _zip_recursive(resource_path, base_path, zip); zipClose(zip, nullptr); - Ref<FileAccess> f = FileAccess::open(output_path, FileAccess::READ); - ERR_FAIL_COND_MSG(f.is_null(), "Unable to create ZIP file."); - Vector<uint8_t> buf; - buf.resize(f->get_length()); - f->get_buffer(buf.ptrw(), buf.size()); - godot_js_os_download_buffer(buf.ptr(), buf.size(), output_name.utf8().get_data(), "application/zip"); + { + Ref<FileAccess> f = FileAccess::open(output_path, FileAccess::READ); + ERR_FAIL_COND_MSG(f.is_null(), "Unable to create ZIP file."); + Vector<uint8_t> buf; + buf.resize(f->get_length()); + f->get_buffer(buf.ptrw(), buf.size()); + godot_js_os_download_buffer(buf.ptr(), buf.size(), output_name.utf8().get_data(), "application/zip"); + } // Remove the temporary file since it was sent to the user's native filesystem as a download. DirAccess::remove_file_or_error(output_path); |