LibGfx/PortableFormat: Propagate errors from decode()

This commit is contained in:
Lucas CHOLLET 2023-03-12 23:03:08 -04:00 committed by Andreas Kling
commit fd04b2dc9b
Notes: sideshowbarker 2024-07-17 17:38:29 +09:00
2 changed files with 20 additions and 34 deletions

View file

@ -93,9 +93,11 @@ IntSize PortableImageDecoderPlugin<TContext>::size()
return {};
if (m_context->state < TContext::State::Decoded) {
bool success = decode(*m_context);
if (!success)
if (decode(*m_context).is_error()) {
m_context->state = TContext::State::Error;
// FIXME: We should propagate errors
return {};
}
}
return { m_context->width, m_context->height };
@ -168,9 +170,10 @@ ErrorOr<ImageFrameDescriptor> PortableImageDecoderPlugin<TContext>::frame(size_t
return Error::from_string_literal("PortableImageDecoderPlugin: Decoding failed");
if (m_context->state < TContext::State::Decoded) {
bool success = decode(*m_context);
if (!success)
if (decode(*m_context).is_error()) {
m_context->state = TContext::State::Error;
return Error::from_string_literal("PortableImageDecoderPlugin: Decoding failed");
}
}
VERIFY(m_context->bitmap);