diff options
author | Cygnix Proto <99915288+CygnixProto@users.noreply.github.com> | 2022-12-06 16:26:13 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-14 18:25:28 +0000 |
commit | 806a55eda1d2e76c52fcea2ef11b81f2967b6e74 (patch) | |
tree | 21533574a8c71ac1a5af844319d2a0b1f8a853d3 /Userland/Applications/ThemeEditor/MainWidget.cpp | |
parent | bdd9bc16ded4c55e5e479b2b2357afc99ce65da8 (diff) | |
download | serenity-806a55eda1d2e76c52fcea2ef11b81f2967b6e74.zip |
LibGfx+Userland: Make Gfx::SystemTheme propagate errors
This patch introduces error propagation to Gfx::SystemTheme to remove
instances of release_value_but_fixme_should_propagate_errors().
Userland applications that have been affected by this change have been
updated to utilise this propagation and as a result 4 such instances of
the aforementioned method have been removed.
Diffstat (limited to 'Userland/Applications/ThemeEditor/MainWidget.cpp')
-rw-r--r-- | Userland/Applications/ThemeEditor/MainWidget.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index 2ac9815f34..0c823b9b9a 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -208,7 +208,11 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window) auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Select theme file", "/res/themes"sv); if (response.is_error()) return; - load_from_file(*response.value()); + auto load_from_file_result = load_from_file(*response.value()); + if (load_from_file_result.is_error()) { + GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Can't open file named {}: {}", response.value()->filename(), load_from_file_result.error())); + return; + } }))); m_save_action = GUI::CommonActions::make_save_action([&](auto&) { @@ -557,10 +561,10 @@ void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI:: path_input.set_text(*result); } -void MainWidget::load_from_file(Core::File& file) +ErrorOr<void> MainWidget::load_from_file(Core::File& file) { - auto config_file = Core::ConfigFile::open(file.filename(), file.leak_fd()).release_value_but_fixme_should_propagate_errors(); - auto theme = Gfx::load_system_theme(config_file); + auto config_file = TRY(Core::ConfigFile::open(file.filename(), file.leak_fd())); + auto theme = TRY(Gfx::load_system_theme(config_file)); VERIFY(theme.is_valid()); auto new_palette = Gfx::Palette(Gfx::PaletteImpl::create_with_anonymous_buffer(theme)); @@ -599,6 +603,7 @@ void MainWidget::load_from_file(Core::File& file) m_last_modified_time = Time::now_monotonic(); window()->set_modified(false); + return {}; } } |