mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
LibGfx+Fallout: Make ImageDecoder return ErrorOr
...from try_create_for_raw_bytes(). If a plugin returns `true` from sniff but then fails when calling its `create()` method, we now no longer swallow that error. Allows `image` (and other places in the system) to print a more actionable error if early image headers are invalid. (We now no longer try to find another plugin that can also handle the image.) Fixes a regression from #20063 / #19893 -- before then, we didn't do fallible work this early.
This commit is contained in:
@@ -43,11 +43,12 @@ static void decode_image_to_details(Core::AnonymousBuffer const& encoded_buffer,
|
||||
VERIFY(bitmaps.size() == 0);
|
||||
VERIFY(durations.size() == 0);
|
||||
|
||||
auto decoder = Gfx::ImageDecoder::try_create_for_raw_bytes(ReadonlyBytes { encoded_buffer.data<u8>(), encoded_buffer.size() }, known_mime_type);
|
||||
if (!decoder) {
|
||||
auto decoder_or_err = Gfx::ImageDecoder::try_create_for_raw_bytes(ReadonlyBytes { encoded_buffer.data<u8>(), encoded_buffer.size() }, known_mime_type);
|
||||
if (decoder_or_err.is_error() || !decoder_or_err.value()) {
|
||||
dbgln_if(IMAGE_DECODER_DEBUG, "Could not find suitable image decoder plugin for data");
|
||||
return;
|
||||
}
|
||||
auto decoder = decoder_or_err.release_value();
|
||||
|
||||
if (!decoder->frame_count()) {
|
||||
dbgln_if(IMAGE_DECODER_DEBUG, "Could not decode image from encoded data");
|
||||
|
||||
Reference in New Issue
Block a user