Fix crash in ResourceImporterTexture::_save_stex if webp disabled

Fixes #51535.

(cherry picked from commit 79d4edfca7)
This commit is contained in:
Chained Lupine 2021-08-13 15:17:55 -05:00 committed by Rémi Verschelde
parent e4996887ca
commit 44a532e99e
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 2 additions and 1 deletions

View File

@ -256,7 +256,8 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
switch (p_compress_mode) {
case COMPRESS_LOSSLESS: {
bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/misc/lossless_compression/force_png");
bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/misc/lossless_compression/force_png") ||
!Image::_webp_mem_loader_func; // WebP module disabled.
bool use_webp = !lossless_force_png && p_image->get_width() <= 16383 && p_image->get_height() <= 16383; // WebP has a size limit
Ref<Image> image = p_image->duplicate();
if (p_mipmaps) {