mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +00:00
PixelPaint: Display an error message if opening a file fails
This commit is contained in:
parent
c333aec9f3
commit
8731bc9ead
3 changed files with 48 additions and 38 deletions
|
@ -96,13 +96,14 @@ int main(int argc, char** argv)
|
|||
window);
|
||||
|
||||
auto open_image_file = [&](auto& path) {
|
||||
auto image = PixelPaint::Image::try_create_from_file(path);
|
||||
if (!image) {
|
||||
GUI::MessageBox::show_error(window, String::formatted("Invalid image file: {}", path));
|
||||
auto image_or_error = PixelPaint::Image::try_create_from_file(path);
|
||||
if (image_or_error.is_error()) {
|
||||
GUI::MessageBox::show_error(window, String::formatted("Unable to open file: {}", path));
|
||||
return;
|
||||
}
|
||||
auto& image = *image_or_error.value();
|
||||
image_editor.set_image(image);
|
||||
layer_list_widget.set_image(image);
|
||||
layer_list_widget.set_image(&image);
|
||||
};
|
||||
|
||||
auto open_image_action = GUI::CommonActions::make_open_action([&](auto&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue