summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter-Jan Briers <pieterjan.briers@gmail.com>2018-05-12 16:53:45 +0200
committerPieter-Jan Briers <pieterjan.briers@gmail.com>2018-05-14 19:11:41 +0200
commit622a754584d2b9442aee3d5c3835556451225262 (patch)
treeb5ea9e05c90b43b4a50aa477a8e3fce71d5ebca8
parent81b1d3c846de263cf843e9e0e9d7c0c0a94f65c8 (diff)
ImageTexture.load returns an error code.
-rw-r--r--doc/classes/Image.xml2
-rw-r--r--doc/classes/ImageTexture.xml4
-rw-r--r--scene/resources/texture.cpp9
-rw-r--r--scene/resources/texture.h2
4 files changed, 11 insertions, 6 deletions
diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml
index ca2d519e8a..760b0c6bdc 100644
--- a/doc/classes/Image.xml
+++ b/doc/classes/Image.xml
@@ -338,6 +338,7 @@
<argument index="0" name="buffer" type="PoolByteArray">
</argument>
<description>
+ Loads an image from the binary contents of a JPEG file.
</description>
</method>
<method name="load_png_from_buffer">
@@ -346,6 +347,7 @@
<argument index="0" name="buffer" type="PoolByteArray">
</argument>
<description>
+ Loads an image from the binary contents of a PNG file.
</description>
</method>
<method name="lock">
diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml
index 9a5937299c..0bff3317db 100644
--- a/doc/classes/ImageTexture.xml
+++ b/doc/classes/ImageTexture.xml
@@ -47,12 +47,12 @@
</description>
</method>
<method name="load">
- <return type="void">
+ <return type="int" enum="Error">
</return>
<argument index="0" name="path" type="String">
</argument>
<description>
- Load an [code]ImageTexture[/code].
+ Load an [code]ImageTexture[/code] from a file path.
</description>
</method>
<method name="set_data">
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index c0f6756fd1..56a2e7afba 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 93d7ec4ef9..d81fd3b19b 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;