diff options
| author | Rémi Verschelde | 2018-05-16 23:23:08 +0200 |
|---|---|---|
| committer | GitHub | 2018-05-16 23:23:08 +0200 |
| commit | 2cf36651b968e99602445678e1fa6ea0adfc078a (patch) | |
| tree | 5c4dbb878ba35ef895c099621c4224581957fa78 /scene/resources | |
| parent | 97b1e8b5175478d1f09f72aa72f6d98b655f56a4 (diff) | |
| parent | 622a754584d2b9442aee3d5c3835556451225262 (diff) | |
| download | godot-2cf36651b968e99602445678e1fa6ea0adfc078a.tar.gz godot-2cf36651b968e99602445678e1fa6ea0adfc078a.tar.zst godot-2cf36651b968e99602445678e1fa6ea0adfc078a.zip | |
Merge pull request #18814 from PJB3005/18-05-12-imagetexture-load-error
ImageTexture.load returns an error code.
Diffstat (limited to 'scene/resources')
| -rw-r--r-- | scene/resources/texture.cpp | 9 | ||||
| -rw-r--r-- | scene/resources/texture.h | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index c0f6756fd..56a2e7afb 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -220,12 +220,15 @@ Image::Format ImageTexture::get_format() const { return format; } -void ImageTexture::load(const String &p_path) { +Error ImageTexture::load(const String &p_path) { Ref<Image> img; img.instance(); - img->load(p_path); - create_from_image(img); + Error err = img->load(p_path); + if (err == OK) { + create_from_image(img); + } + return err; } void ImageTexture::set_data(const Ref<Image> &p_image) { diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 93d7ec4ef..d81fd3b19 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -124,7 +124,7 @@ public: void set_flags(uint32_t p_flags); uint32_t get_flags() const; Image::Format get_format() const; - void load(const String &p_path); + Error load(const String &p_path); void set_data(const Ref<Image> &p_image); Ref<Image> get_data() const; |
