@@ -1099,7 +1099,11 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
10991099
11001100 ERR_FAIL_COND_V (data.is_empty (), Ref<Image>());
11011101 image = Image::create_from_data (texture->alloc_width , texture->alloc_height , texture->mipmaps > 1 , texture->real_format , data);
1102- ERR_FAIL_COND_V (image->is_empty (), Ref<Image>());
1102+ if (image->is_empty ()) {
1103+ const String &path_str = texture->path .is_empty () ? " with no path" : vformat (" with path '%s'" , texture->path );
1104+ ERR_FAIL_V_MSG (Ref<Image>(), vformat (" Texture %s has no data." , path_str));
1105+ }
1106+
11031107 if (texture->format != texture->real_format ) {
11041108 image->convert (texture->format );
11051109 }
@@ -1155,7 +1159,10 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
11551159
11561160 ERR_FAIL_COND_V (data.is_empty (), Ref<Image>());
11571161 image = Image::create_from_data (texture->alloc_width , texture->alloc_height , false , Image::FORMAT_RGBA8, data);
1158- ERR_FAIL_COND_V (image->is_empty (), Ref<Image>());
1162+ if (image->is_empty ()) {
1163+ const String &path_str = texture->path .is_empty () ? " with no path" : vformat (" with path '%s'" , texture->path );
1164+ ERR_FAIL_V_MSG (Ref<Image>(), vformat (" Texture %s has no data." , path_str));
1165+ }
11591166
11601167 if (texture->format != Image::FORMAT_RGBA8) {
11611168 image->convert (texture->format );
@@ -1227,7 +1234,10 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
12271234
12281235 ERR_FAIL_COND_V (data.is_empty (), Ref<Image>());
12291236 Ref<Image> image = Image::create_from_data (texture->width , texture->height , false , Image::FORMAT_RGBA8, data);
1230- ERR_FAIL_COND_V (image->is_empty (), Ref<Image>());
1237+ if (image->is_empty ()) {
1238+ const String &path_str = texture->path .is_empty () ? " with no path" : vformat (" with path '%s'" , texture->path );
1239+ ERR_FAIL_V_MSG (Ref<Image>(), vformat (" Texture %s has no data." , path_str));
1240+ }
12311241
12321242 if (texture->format != Image::FORMAT_RGBA8) {
12331243 image->convert (texture->format );
0 commit comments