summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-13 17:20:42 +0200
committerGitHub <noreply@github.com>2019-05-13 17:20:42 +0200
commit868ee3ea10c4101aa941fcf08c3da13c3394df15 (patch)
tree98674b6078452d0d9bfe3dba4585d169ad4f12a0 /scene/resources
parent8667e4abf7d7087f384751447e94a585be400607 (diff)
parente34eb5c26caf4a0a68f8c84f0e02893e4be2eeb6 (diff)
Merge pull request #28761 from aqnuep/texture_resource_reload_fix
Fix texture resource reload bug
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/texture.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index a5eb950c36..92172912c2 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -111,10 +111,12 @@ void ImageTexture::reload_from_file() {
Ref<Image> img;
img.instance();
- Error err = ImageLoader::load_image(path, img);
- ERR_FAIL_COND(err != OK);
-
- create_from_image(img, flags);
+ if (ImageLoader::load_image(path, img) == OK) {
+ create_from_image(img, flags);
+ } else {
+ Resource::reload_from_file();
+ _change_notify();
+ }
}
bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {
@@ -638,7 +640,7 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_
bool mipmaps = df & FORMAT_BIT_HAS_MIPMAPS;
if (!mipmaps) {
- int size = Image::get_image_data_size(tw, th, format, 0);
+ int size = Image::get_image_data_size(tw, th, format, false);
PoolVector<uint8_t> img_data;
img_data.resize(size);
@@ -660,7 +662,6 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_
int mipmaps2 = Image::get_image_required_mipmaps(tw, th, format);
int total_size = Image::get_image_data_size(tw, th, format, true);
int idx = 0;
- int ofs = 0;
while (mipmaps2 > 1 && p_size_limit > 0 && (sw > p_size_limit || sh > p_size_limit)) {
@@ -670,9 +671,7 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_
idx++;
}
- if (idx > 0) {
- ofs = Image::get_image_data_size(tw, th, format, idx - 1);
- }
+ int ofs = Image::get_image_mipmap_offset(tw, th, format, idx);
if (total_size - ofs <= 0) {
memdelete(f);