1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:27:34 +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:
Nico Weber 2024-03-04 18:07:43 -05:00 committed by Tim Flynn
parent be5e7a360f
commit 2e2cae26c6
12 changed files with 22 additions and 22 deletions

View file

@ -147,7 +147,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::load_from_file(NonnullOwnPtr<Core::File>
ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::load_from_bytes(ReadonlyBytes bytes, Optional<IntSize> ideal_size, Optional<ByteString> mine_type)
{
if (auto decoder = ImageDecoder::try_create_for_raw_bytes(bytes, mine_type)) {
if (auto decoder = TRY(ImageDecoder::try_create_for_raw_bytes(bytes, mine_type))) {
auto frame = TRY(decoder->frame(0, ideal_size));
if (auto& bitmap = frame.image)
return bitmap.release_nonnull();