diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 67d82fc646..833241a5e9 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -55,7 +55,7 @@ void ViewWidget::flip(Gfx::Orientation orientation) void ViewWidget::rotate(Gfx::RotationDirection rotation_direction) { - m_bitmap = m_bitmap->rotated(rotation_direction); + m_bitmap = m_bitmap->rotated(rotation_direction).release_value_but_fixme_should_propagate_errors(); set_scale(m_scale); resize_window(); diff --git a/Userland/Applications/PDFViewer/PDFViewer.cpp b/Userland/Applications/PDFViewer/PDFViewer.cpp index b41b857299..15b1e38d95 100644 --- a/Userland/Applications/PDFViewer/PDFViewer.cpp +++ b/Userland/Applications/PDFViewer/PDFViewer.cpp @@ -152,10 +152,10 @@ RefPtr PDFViewer::render_page(const PDF::Page& page) if (page.rotate != 0) { int rotation_count = (page.rotate / 90) % 4; if (rotation_count == 3) { - bitmap = bitmap->rotated(Gfx::RotationDirection::CounterClockwise); + bitmap = bitmap->rotated(Gfx::RotationDirection::CounterClockwise).release_value_but_fixme_should_propagate_errors(); } else { for (int i = 0; i < rotation_count; i++) - bitmap = bitmap->rotated(Gfx::RotationDirection::Clockwise); + bitmap = bitmap->rotated(Gfx::RotationDirection::Clockwise).release_value_but_fixme_should_propagate_errors(); } } diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 5796472f3e..6ab9081b5a 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -518,8 +518,7 @@ void Image::flip(Gfx::Orientation orientation) void Image::rotate(Gfx::RotationDirection direction) { for (auto& layer : m_layers) { - auto rotated = layer.bitmap().rotated(direction); - VERIFY(rotated); + auto rotated = layer.bitmap().rotated(direction).release_value_but_fixme_should_propagate_errors(); layer.set_bitmap(*rotated); layer.did_modify_bitmap(rect()); } diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 5090434917..eb08fc8880 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -347,11 +347,13 @@ ErrorOr> Bitmap::clone() const return new_bitmap.release_nonnull(); } -RefPtr Bitmap::rotated(Gfx::RotationDirection rotation_direction) const +ErrorOr> Bitmap::rotated(Gfx::RotationDirection rotation_direction) const { auto new_bitmap = Gfx::Bitmap::try_create(this->format(), { height(), width() }, 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(); @@ -367,7 +369,7 @@ RefPtr Bitmap::rotated(Gfx::RotationDirection rotation_direction) c } } - return new_bitmap; + return new_bitmap.release_nonnull(); } RefPtr Bitmap::flipped(Gfx::Orientation orientation) const diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index b7c2f25e31..36a312f24e 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -111,7 +111,7 @@ public: ErrorOr> clone() const; - [[nodiscard]] RefPtr rotated(Gfx::RotationDirection) const; + ErrorOr> rotated(Gfx::RotationDirection) const; [[nodiscard]] RefPtr flipped(Gfx::Orientation) const; [[nodiscard]] RefPtr scaled(int sx, int sy) const; [[nodiscard]] RefPtr scaled(float sx, float sy) const;