summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-12 10:26:46 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-12 11:19:29 +0200
commit92203c9821b53447a66ada699913e5e657551abf (patch)
treea9cc415f25870623a0ce07a8dd5fbcfd2e6c1313 /Userland/Applications/PixelPaint
parent9038bc675fa43ff9acb4aadcdca2dd181e7d712d (diff)
downloadserenity-92203c9821b53447a66ada699913e5e657551abf.zip
PixelPaint: Don't allow Image::try_create_from_bitmap(nullptr)
This is not a valid use-case so let's prevent it at compile time.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r--Userland/Applications/PixelPaint/Image.cpp4
-rw-r--r--Userland/Applications/PixelPaint/Image.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp
index 967443c737..7b24f06967 100644
--- a/Userland/Applications/PixelPaint/Image.cpp
+++ b/Userland/Applications/PixelPaint/Image.cpp
@@ -52,7 +52,7 @@ void Image::paint_into(GUI::Painter& painter, Gfx::IntRect const& dest_rect)
}
}
-RefPtr<Image> Image::try_create_from_bitmap(RefPtr<Gfx::Bitmap> bitmap)
+RefPtr<Image> Image::try_create_from_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)
{
auto image = try_create_with_size({ bitmap->width(), bitmap->height() });
if (!image)
@@ -110,7 +110,7 @@ RefPtr<Image> Image::try_create_from_pixel_paint_file(String const& file_path)
RefPtr<Image> Image::try_create_from_file(String const& file_path)
{
if (auto bitmap = Gfx::Bitmap::load_from_file(file_path))
- return try_create_from_bitmap(bitmap);
+ return try_create_from_bitmap(bitmap.release_nonnull());
return try_create_from_pixel_paint_file(file_path);
}
diff --git a/Userland/Applications/PixelPaint/Image.h b/Userland/Applications/PixelPaint/Image.h
index ee1590af79..cb5090d94b 100644
--- a/Userland/Applications/PixelPaint/Image.h
+++ b/Userland/Applications/PixelPaint/Image.h
@@ -38,7 +38,7 @@ class Image : public RefCounted<Image> {
public:
static RefPtr<Image> try_create_with_size(Gfx::IntSize const&);
static RefPtr<Image> try_create_from_file(String const& file_path);
- static RefPtr<Image> try_create_from_bitmap(RefPtr<Gfx::Bitmap> bitmap);
+ static RefPtr<Image> try_create_from_bitmap(NonnullRefPtr<Gfx::Bitmap>);
size_t layer_count() const { return m_layers.size(); }
Layer const& layer(size_t index) const { return m_layers.at(index); }