Make FileAccess and DirAccess classes reference counted.
This commit is contained in:
@ -37,7 +37,7 @@
|
||||
|
||||
#include "thirdparty/tinyexr/tinyexr.h"
|
||||
|
||||
Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
|
||||
Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, Ref<FileAccess> f, bool p_force_linear, float p_scale) {
|
||||
Vector<uint8_t> src_image;
|
||||
uint64_t src_image_len = f->get_length();
|
||||
ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
|
||||
@ -47,8 +47,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
|
||||
|
||||
f->get_buffer(&w[0], src_image_len);
|
||||
|
||||
f->close();
|
||||
|
||||
// Re-implementation of tinyexr's LoadEXRFromMemory using Godot types to store the Image data
|
||||
// and Godot's error codes.
|
||||
// When debugging after updating the thirdparty library, check that we're still in sync with
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
class ImageLoaderTinyEXR : public ImageFormatLoader {
|
||||
public:
|
||||
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
|
||||
virtual Error load_image(Ref<Image> p_image, Ref<FileAccess> f, bool p_force_linear, float p_scale);
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
ImageLoaderTinyEXR();
|
||||
};
|
||||
|
||||
@ -275,8 +275,8 @@ Error save_exr(const String &p_path, const Ref<Image> &p_img, bool p_grayscale)
|
||||
print_error(String("Saving EXR failed. Error: {0}").format(varray(err)));
|
||||
return ERR_FILE_CANT_WRITE;
|
||||
} else {
|
||||
FileAccessRef ref = FileAccess::open(p_path, FileAccess::WRITE);
|
||||
ERR_FAIL_COND_V(!ref, ERR_FILE_CANT_WRITE);
|
||||
Ref<FileAccess> ref = FileAccess::open(p_path, FileAccess::WRITE);
|
||||
ERR_FAIL_COND_V(ref.is_null(), ERR_FILE_CANT_WRITE);
|
||||
ref->store_buffer(mem, bytes);
|
||||
free(mem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user