Skip to content

Commit fb75078

Browse files
committed
Changed some image error messages to print the file path
1 parent 6c05ec3 commit fb75078

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

drivers/gles3/storage/texture_storage.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

servers/rendering/renderer_rd/storage_rd/texture_storage.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,11 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
14461446
image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
14471447
}
14481448

1449-
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
1449+
if (image->is_empty()) {
1450+
const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path);
1451+
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
1452+
}
1453+
14501454
if (tex->format != tex->validated_format) {
14511455
image->convert(tex->format);
14521456
}
@@ -1467,7 +1471,10 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
14671471
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
14681472
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
14691473
Ref<Image> image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
1470-
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
1474+
if (image->is_empty()) {
1475+
const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path);
1476+
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
1477+
}
14711478
if (tex->format != tex->validated_format) {
14721479
image->convert(tex->format);
14731480
}
@@ -1494,6 +1501,10 @@ Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
14941501

14951502
Ref<Image> img = Image::create_from_data(bs.size.width, bs.size.height, false, tex->validated_format, sub_region);
14961503
ERR_FAIL_COND_V(img->is_empty(), Vector<Ref<Image>>());
1504+
if (img->is_empty()) {
1505+
const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path);
1506+
ERR_FAIL_V_MSG(Vector<Ref<Image>>(), vformat("Texture %s has no data.", path_str));
1507+
}
14971508
if (tex->format != tex->validated_format) {
14981509
img->convert(tex->format);
14991510
}

0 commit comments

Comments
 (0)