1
0
Fork 0

Changed some image error messages to print the file path

This commit is contained in:
Chris 2024-11-15 20:42:03 +01:00
parent 6c05ec3d67
commit fb75078308
2 changed files with 26 additions and 5 deletions

View File

@ -1099,7 +1099,11 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
image = Image::create_from_data(texture->alloc_width, texture->alloc_height, texture->mipmaps > 1, texture->real_format, data);
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (image->is_empty()) {
const String &path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path);
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
}
if (texture->format != texture->real_format) {
image->convert(texture->format);
}
@ -1155,7 +1159,10 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
image = Image::create_from_data(texture->alloc_width, texture->alloc_height, false, Image::FORMAT_RGBA8, data);
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (image->is_empty()) {
const String &path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path);
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
}
if (texture->format != Image::FORMAT_RGBA8) {
image->convert(texture->format);
@ -1227,7 +1234,10 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
Ref<Image> image = Image::create_from_data(texture->width, texture->height, false, Image::FORMAT_RGBA8, data);
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (image->is_empty()) {
const String &path_str = texture->path.is_empty() ? "with no path" : vformat("with path '%s'", texture->path);
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
}
if (texture->format != Image::FORMAT_RGBA8) {
image->convert(texture->format);

View File

@ -1446,7 +1446,11 @@ Ref<Image> TextureStorage::texture_2d_get(RID p_texture) const {
image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
}
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (image->is_empty()) {
const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path);
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
}
if (tex->format != tex->validated_format) {
image->convert(tex->format);
}
@ -1467,7 +1471,10 @@ Ref<Image> TextureStorage::texture_2d_layer_get(RID p_texture, int p_layer) cons
Vector<uint8_t> data = RD::get_singleton()->texture_get_data(tex->rd_texture, p_layer);
ERR_FAIL_COND_V(data.is_empty(), Ref<Image>());
Ref<Image> image = Image::create_from_data(tex->width, tex->height, tex->mipmaps > 1, tex->validated_format, data);
ERR_FAIL_COND_V(image->is_empty(), Ref<Image>());
if (image->is_empty()) {
const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path);
ERR_FAIL_V_MSG(Ref<Image>(), vformat("Texture %s has no data.", path_str));
}
if (tex->format != tex->validated_format) {
image->convert(tex->format);
}
@ -1494,6 +1501,10 @@ Vector<Ref<Image>> TextureStorage::texture_3d_get(RID p_texture) const {
Ref<Image> img = Image::create_from_data(bs.size.width, bs.size.height, false, tex->validated_format, sub_region);
ERR_FAIL_COND_V(img->is_empty(), Vector<Ref<Image>>());
if (img->is_empty()) {
const String &path_str = tex->path.is_empty() ? "with no path" : vformat("with path '%s'", tex->path);
ERR_FAIL_V_MSG(Vector<Ref<Image>>(), vformat("Texture %s has no data.", path_str));
}
if (tex->format != tex->validated_format) {
img->convert(tex->format);
}