mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:47:46 +00:00
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.
This commit is contained in:
parent
bdd9bc16de
commit
806a55eda1
15 changed files with 64 additions and 39 deletions
|
@ -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 {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
ErrorOr<void> initialize_menubar(GUI::Window&);
|
||||
GUI::Window::CloseRequestDecision request_close();
|
||||
void update_title();
|
||||
void load_from_file(Core::File&);
|
||||
ErrorOr<void> load_from_file(Core::File&);
|
||||
|
||||
private:
|
||||
MainWidget();
|
||||
|
|
|
@ -160,7 +160,10 @@ void PreviewWidget::drop_event(GUI::DropEvent& event)
|
|||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
set_theme_from_file(*response.value());
|
||||
|
||||
auto set_theme_from_file_result = set_theme_from_file(response.release_value());
|
||||
if (set_theme_from_file_result.is_error())
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Setting theme from file has failed: {}", set_theme_from_file_result.error()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, path.value());
|
||||
if (response.is_error())
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("Opening \"{}\" failed: {}", path.value(), response.error()));
|
||||
else
|
||||
main_widget->load_from_file(response.release_value());
|
||||
else {
|
||||
auto load_from_file_result = main_widget->load_from_file(response.release_value());
|
||||
if (load_from_file_result.is_error())
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("Loading theme from file has failed: {}", load_from_file_result.error()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue