mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
PixelPaint: Propagate errors using try_set_main_widget in main
This commit is contained in:
parent
6f283a8e60
commit
45e68b2aa4
1 changed files with 6 additions and 6 deletions
|
@ -45,17 +45,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
window->resize(800, 510);
|
window->resize(800, 510);
|
||||||
window->set_icon(app_icon.bitmap_for_size(16));
|
window->set_icon(app_icon.bitmap_for_size(16));
|
||||||
|
|
||||||
auto& main_widget = window->set_main_widget<PixelPaint::MainWidget>();
|
auto main_widget = TRY(window->try_set_main_widget<PixelPaint::MainWidget>());
|
||||||
|
|
||||||
main_widget.initialize_menubar(*window);
|
main_widget->initialize_menubar(*window);
|
||||||
|
|
||||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||||
if (main_widget.request_close())
|
if (main_widget->request_close())
|
||||||
return GUI::Window::CloseRequestDecision::Close;
|
return GUI::Window::CloseRequestDecision::Close;
|
||||||
return GUI::Window::CloseRequestDecision::StayOpen;
|
return GUI::Window::CloseRequestDecision::StayOpen;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto& statusbar = *main_widget.find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
auto& statusbar = *main_widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
||||||
|
|
||||||
app->on_action_enter = [&statusbar](GUI::Action& action) {
|
app->on_action_enter = [&statusbar](GUI::Action& action) {
|
||||||
auto text = action.status_tip();
|
auto text = action.status_tip();
|
||||||
|
@ -77,9 +77,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
GUI::MessageBox::show_error(window, String::formatted("Opening \"{}\" failed: {}", *response.chosen_file, strerror(response.error)));
|
GUI::MessageBox::show_error(window, String::formatted("Opening \"{}\" failed: {}", *response.chosen_file, strerror(response.error)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
main_widget.open_image_fd(*response.fd, *response.chosen_file);
|
main_widget->open_image_fd(*response.fd, *response.chosen_file);
|
||||||
} else {
|
} else {
|
||||||
main_widget.create_default_image();
|
main_widget->create_default_image();
|
||||||
}
|
}
|
||||||
|
|
||||||
return app->exec();
|
return app->exec();
|
||||||
|
|
Loading…
Add table
Reference in a new issue