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/Services | |
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/Services')
-rw-r--r-- | Userland/Services/Taskbar/main.cpp | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.cpp | 10 | ||||
-rw-r--r-- | Userland/Services/WindowServer/main.cpp | 3 |
3 files changed, 8 insertions, 7 deletions
diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp index 1dede77962..ed57f2ccc2 100644 --- a/Userland/Services/Taskbar/main.cpp +++ b/Userland/Services/Taskbar/main.cpp @@ -227,7 +227,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window) g_themes_menu = &system_menu->add_submenu("&Themes"); g_themes_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/themes.png"sv).release_value_but_fixme_should_propagate_errors()); - g_themes = Gfx::list_installed_system_themes(); + g_themes = TRY(Gfx::list_installed_system_themes()); auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme(); { diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 128e8d0f98..95fd787e4e 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -2064,9 +2064,12 @@ void WindowManager::invalidate_after_theme_or_font_change() bool WindowManager::update_theme(DeprecatedString theme_path, DeprecatedString theme_name, bool keep_desktop_background) { - auto new_theme = Gfx::load_system_theme(theme_path); - if (!new_theme.is_valid()) + auto error_or_new_theme = Gfx::load_system_theme(theme_path); + if (error_or_new_theme.is_error()) { + dbgln("WindowManager: Updating theme failed, error {}", error_or_new_theme.error()); return false; + } + auto new_theme = error_or_new_theme.release_value(); m_theme_overridden = false; Gfx::set_system_theme(new_theme); m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme); @@ -2101,8 +2104,7 @@ void WindowManager::clear_theme_override() { m_theme_overridden = false; auto previous_theme_name = m_config->read_entry("Theme", "Name"); - auto previous_theme = Gfx::load_system_theme(DeprecatedString::formatted("/res/themes/{}.ini", previous_theme_name)); - VERIFY(previous_theme.is_valid()); + auto previous_theme = MUST(Gfx::load_system_theme(DeprecatedString::formatted("/res/themes/{}.ini", previous_theme_name))); Gfx::set_system_theme(previous_theme); m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(previous_theme); invalidate_after_theme_or_font_change(); diff --git a/Userland/Services/WindowServer/main.cpp b/Userland/Services/WindowServer/main.cpp index 06a9a9375a..2238e32ce8 100644 --- a/Userland/Services/WindowServer/main.cpp +++ b/Userland/Services/WindowServer/main.cpp @@ -44,8 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments) auto wm_config = TRY(Core::ConfigFile::open("/etc/WindowServer.ini")); auto theme_name = wm_config->read_entry("Theme", "Name", "Default"); - auto theme = Gfx::load_system_theme(DeprecatedString::formatted("/res/themes/{}.ini", theme_name)); - VERIFY(theme.is_valid()); + auto theme = TRY(Gfx::load_system_theme(DeprecatedString::formatted("/res/themes/{}.ini", theme_name))); Gfx::set_system_theme(theme); auto palette = Gfx::PaletteImpl::create_with_anonymous_buffer(theme); |