From 0c24522635ec7f07e1fb69d9e1cd350d81e2248f Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 6 Jan 2023 16:48:37 +0000 Subject: LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^) Rip that bandaid off! This does the following, in one big, awkward jump: - Replace all uses of `set_main_widget()` with the `try` version. - Remove `set_main_widget()`. - Rename the `try` version to just be `set_main_widget` because it's now the only one. The majority of places that call `set_main_widget()` are inside constructors, so this unfortunately gives us a big batch of new `release_value_but_fixme_should_propagate_errors()` calls. --- Userland/Games/Chess/PromotionDialog.cpp | 10 +++++----- Userland/Games/Chess/main.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'Userland/Games/Chess') diff --git a/Userland/Games/Chess/PromotionDialog.cpp b/Userland/Games/Chess/PromotionDialog.cpp index f20ab09148..06e742ae24 100644 --- a/Userland/Games/Chess/PromotionDialog.cpp +++ b/Userland/Games/Chess/PromotionDialog.cpp @@ -17,13 +17,13 @@ PromotionDialog::PromotionDialog(ChessWidget& chess_widget) set_icon(chess_widget.window()->icon()); resize(70 * 4, 70); - auto& main_widget = set_main_widget(); - main_widget.set_frame_shape(Gfx::FrameShape::Container); - main_widget.set_fill_with_background_color(true); - main_widget.set_layout(); + auto main_widget = set_main_widget().release_value_but_fixme_should_propagate_errors(); + main_widget->set_frame_shape(Gfx::FrameShape::Container); + main_widget->set_fill_with_background_color(true); + main_widget->set_layout(); for (auto const& type : { Chess::Type::Queen, Chess::Type::Knight, Chess::Type::Rook, Chess::Type::Bishop }) { - auto& button = main_widget.add(""); + auto& button = main_widget->add(""); button.set_fixed_height(70); button.set_icon(chess_widget.get_piece_graphic({ chess_widget.board().turn(), type })); button.on_click = [this, type](auto) { diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index 5dfa1145fd..8e40931ec3 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -34,7 +34,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess"sv)); auto window = TRY(GUI::Window::try_create()); - auto widget = TRY(window->try_set_main_widget()); + auto widget = TRY(window->set_main_widget()); TRY(Core::System::unveil("/sys/kernel/processes", "r")); TRY(Core::System::unveil("/res", "r")); -- cgit v1.2.3