mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +00:00
PixelPaint: Make "Add Mask" action fallible
This commit is contained in:
parent
b548a7b5ea
commit
d62c95d779
3 changed files with 10 additions and 4 deletions
|
@ -309,11 +309,12 @@ void Layer::update_cached_bitmap()
|
|||
}
|
||||
}
|
||||
|
||||
void Layer::create_mask()
|
||||
ErrorOr<void> Layer::create_mask()
|
||||
{
|
||||
m_mask_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, size()));
|
||||
m_mask_bitmap = TRY(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, size()));
|
||||
m_mask_bitmap->fill(Gfx::Color::White);
|
||||
update_cached_bitmap();
|
||||
return {};
|
||||
}
|
||||
|
||||
Gfx::Bitmap& Layer::currently_edited_bitmap()
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
Gfx::Bitmap const* mask_bitmap() const { return m_mask_bitmap; }
|
||||
Gfx::Bitmap* mask_bitmap() { return m_mask_bitmap; }
|
||||
|
||||
void create_mask();
|
||||
ErrorOr<void> create_mask();
|
||||
Gfx::Bitmap& get_scratch_edited_bitmap();
|
||||
|
||||
Gfx::IntSize size() const { return content_bitmap().size(); }
|
||||
|
|
|
@ -746,7 +746,12 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
auto active_layer = editor->active_layer();
|
||||
if (!active_layer)
|
||||
return;
|
||||
active_layer->create_mask();
|
||||
|
||||
if (auto maybe_error = active_layer->create_mask(); maybe_error.is_error()) {
|
||||
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Failed to create layer mask: {}", maybe_error.release_error()));
|
||||
return;
|
||||
}
|
||||
|
||||
editor->did_complete_action("Add Mask");
|
||||
editor->update();
|
||||
m_layer_list_widget->repaint();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue