diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 833241a5e9..825a96aa77 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -47,7 +47,7 @@ void ViewWidget::clear() void ViewWidget::flip(Gfx::Orientation orientation) { - m_bitmap = m_bitmap->flipped(orientation); + m_bitmap = m_bitmap->flipped(orientation).release_value_but_fixme_should_propagate_errors(); set_scale(m_scale); resize_window(); diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 6ab9081b5a..f2f3b55090 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -506,8 +506,7 @@ void Image::set_path(String path) void Image::flip(Gfx::Orientation orientation) { for (auto& layer : m_layers) { - auto flipped = layer.bitmap().flipped(orientation); - VERIFY(flipped); + auto flipped = layer.bitmap().flipped(orientation).release_value_but_fixme_should_propagate_errors(); layer.set_bitmap(*flipped); layer.did_modify_bitmap(rect()); } diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index eb08fc8880..ac198aed3f 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -372,11 +372,13 @@ ErrorOr> Bitmap::rotated(Gfx::RotationDirection rotat return new_bitmap.release_nonnull(); } -RefPtr Bitmap::flipped(Gfx::Orientation orientation) const +ErrorOr> Bitmap::flipped(Gfx::Orientation orientation) const { auto new_bitmap = Gfx::Bitmap::try_create(this->format(), { width(), height() }, scale()); - if (!new_bitmap) - return nullptr; + if (!new_bitmap) { + // FIXME: Propagate the *real* error, once we have it. + return Error::from_errno(ENOMEM); + } auto w = this->physical_width(); auto h = this->physical_height(); @@ -390,7 +392,7 @@ RefPtr Bitmap::flipped(Gfx::Orientation orientation) const } } - return new_bitmap; + return new_bitmap.release_nonnull(); } RefPtr Bitmap::scaled(int sx, int sy) const diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index 36a312f24e..ce3726b9fe 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -112,7 +112,7 @@ public: ErrorOr> clone() const; ErrorOr> rotated(Gfx::RotationDirection) const; - [[nodiscard]] RefPtr flipped(Gfx::Orientation) const; + ErrorOr> flipped(Gfx::Orientation) const; [[nodiscard]] RefPtr scaled(int sx, int sy) const; [[nodiscard]] RefPtr scaled(float sx, float sy) const; [[nodiscard]] RefPtr cropped(Gfx::IntRect) const;