summaryrefslogtreecommitdiff
path: root/platform/osx/export
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-04-12 10:12:40 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-04-12 10:54:39 +0300
commit4bf99f4af2c4918883c4382ead7de275fae21eea (patch)
treee741cea7e9395dcffeaa986f34e19819564356fb /platform/osx/export
parent5974e1432ef7941a5e29f8723dec85aa45505963 (diff)
Narrow FileAccess scope to prevent deadlocks.
Diffstat (limited to 'platform/osx/export')
-rw-r--r--platform/osx/export/export_plugin.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp
index 580cd81583..94ef875072 100644
--- a/platform/osx/export/export_plugin.cpp
+++ b/platform/osx/export/export_plugin.cpp
@@ -256,21 +256,23 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_
String path = EditorPaths::get_singleton()->get_cache_dir().plus_file("icon.png");
ResourceSaver::save(path, it);
- Ref<FileAccess> f = FileAccess::open(path, FileAccess::READ);
- if (f.is_null()) {
- // Clean up generated file.
- DirAccess::remove_file_or_error(path);
- ERR_FAIL();
- }
+ {
+ Ref<FileAccess> f = FileAccess::open(path, FileAccess::READ);
+ if (f.is_null()) {
+ // Clean up generated file.
+ DirAccess::remove_file_or_error(path);
+ ERR_FAIL();
+ }
- int ofs = data.size();
- uint64_t len = f->get_length();
- data.resize(data.size() + len + 8);
- f->get_buffer(&data.write[ofs + 8], len);
- len += 8;
- len = BSWAP32(len);
- memcpy(&data.write[ofs], icon_infos[i].name, 4);
- encode_uint32(len, &data.write[ofs + 4]);
+ int ofs = data.size();
+ uint64_t len = f->get_length();
+ data.resize(data.size() + len + 8);
+ f->get_buffer(&data.write[ofs + 8], len);
+ len += 8;
+ len = BSWAP32(len);
+ memcpy(&data.write[ofs], icon_infos[i].name, 4);
+ encode_uint32(len, &data.write[ofs + 4]);
+ }
// Clean up generated file.
DirAccess::remove_file_or_error(path);