1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibGfx: Use ErrorOr<T> for Bitmap::try_create()

Another one that was used in a fajillion places.
This commit is contained in:
Andreas Kling 2021-11-06 19:30:59 +01:00
parent 235f39e449
commit 0de33b3d6c
43 changed files with 157 additions and 141 deletions

View file

@ -168,10 +168,11 @@ Result<void, String> Image::write_to_file(const String& file_path) const
RefPtr<Gfx::Bitmap> Image::try_compose_bitmap(Gfx::BitmapFormat format) const
{
auto bitmap = Gfx::Bitmap::try_create(format, m_size);
if (!bitmap)
auto bitmap_or_error = Gfx::Bitmap::try_create(format, m_size);
if (bitmap_or_error.is_error())
return nullptr;
GUI::Painter painter(*bitmap);
auto bitmap = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
GUI::Painter painter(bitmap);
paint_into(painter, { 0, 0, m_size.width(), m_size.height() });
return bitmap;
}