1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>

This is a first step towards better error propagation from image codecs.
This commit is contained in:
Andreas Kling 2021-11-20 14:29:33 +01:00
parent ae7656072a
commit 5a79c69b02
26 changed files with 101 additions and 100 deletions

View file

@ -56,7 +56,7 @@ void ImageWidget::animate()
{
m_current_frame_index = (m_current_frame_index + 1) % m_image_decoder->frame_count();
const auto& current_frame = m_image_decoder->frame(m_current_frame_index);
auto current_frame = m_image_decoder->frame(m_current_frame_index).release_value_but_fixme_should_propagate_errors();
set_bitmap(current_frame.image);
if (current_frame.duration != m_timer->interval()) {
@ -81,14 +81,14 @@ void ImageWidget::load_from_file(StringView path)
m_image_decoder = Gfx::ImageDecoder::try_create(mapped_file.bytes());
VERIFY(m_image_decoder);
auto frame = m_image_decoder->frame(0);
auto frame = m_image_decoder->frame(0).release_value_but_fixme_should_propagate_errors();
auto bitmap = frame.image;
VERIFY(bitmap);
set_bitmap(bitmap);
if (m_image_decoder->is_animated() && m_image_decoder->frame_count() > 1) {
const auto& first_frame = m_image_decoder->frame(0);
auto first_frame = m_image_decoder->frame(0).release_value_but_fixme_should_propagate_errors();
m_timer->set_interval(first_frame.duration);
m_timer->on_timeout = [this] { animate(); };
m_timer->start();