FontEditor: Propagate errors using try_set_main_widget in main

This commit is contained in:
creator1creeper1 2022-01-07 14:22:48 +01:00 committed by Andreas Kling
parent de82901d4c
commit deed6388ef
Notes: sideshowbarker 2024-07-17 21:22:40 +09:00

View File

@ -43,20 +43,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(440, 470);
auto& font_editor = window->set_main_widget<FontEditorWidget>();
font_editor.initialize_menubar(*window);
auto font_editor = TRY(window->try_set_main_widget<FontEditorWidget>());
font_editor->initialize_menubar(*window);
if (path) {
auto success = font_editor.open_file(path);
auto success = font_editor->open_file(path);
if (!success)
return 1;
} else {
auto mutable_font = static_ptr_cast<Gfx::BitmapFont>(Gfx::FontDatabase::default_font().clone())->unmasked_character_set();
font_editor.initialize({}, move(mutable_font));
font_editor->initialize({}, move(mutable_font));
}
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
if (font_editor.request_close())
if (font_editor->request_close())
return GUI::Window::CloseRequestDecision::Close;
return GUI::Window::CloseRequestDecision::StayOpen;
};