mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
FontEditor: Propagate errors using try_set_main_widget in main
This commit is contained in:
parent
de82901d4c
commit
deed6388ef
Notes:
sideshowbarker
2024-07-17 21:22:40 +09:00
Author: https://github.com/creator1creeper1 Commit: https://github.com/SerenityOS/serenity/commit/deed6388ef0 Pull-request: https://github.com/SerenityOS/serenity/pull/11698
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user