summaryrefslogtreecommitdiff
path: root/Userland/Applications/ThemeEditor/PreviewWidget.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-06 16:25:29 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-08 00:35:27 +0100
commit235f39e449ebffed26114c7166b0b632a3f2232e (patch)
tree3f61715fe8ba3e801803bde270ca4aeca74fd9f5 /Userland/Applications/ThemeEditor/PreviewWidget.cpp
parent16f064d9bea97b499843e1a90a545a738d9c35fd (diff)
downloadserenity-235f39e449ebffed26114c7166b0b632a3f2232e.zip
LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
Diffstat (limited to 'Userland/Applications/ThemeEditor/PreviewWidget.cpp')
-rw-r--r--Userland/Applications/ThemeEditor/PreviewWidget.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp
index eb2ab93e72..ea64fb31b7 100644
--- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp
+++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp
@@ -79,12 +79,12 @@ private:
PreviewWidget::PreviewWidget(const Gfx::Palette& preview_palette)
: m_preview_palette(preview_palette)
{
- m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png");
- m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png");
+ m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
+ m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
- m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png");
- m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png");
- m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png");
+ m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png").release_value_but_fixme_should_propagate_errors();
+ m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors();
+ m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors();
VERIFY(m_active_window_icon);
VERIFY(m_inactive_window_icon);
@@ -105,15 +105,17 @@ PreviewWidget::~PreviewWidget()
void PreviewWidget::load_theme_bitmaps()
{
auto load_bitmap = [](String const& path, String& last_path, RefPtr<Gfx::Bitmap>& bitmap) {
+ bitmap = nullptr;
if (path.is_empty()) {
last_path = String::empty();
- bitmap = nullptr;
} else if (last_path != path) {
- bitmap = Gfx::Bitmap::try_load_from_file(path);
- if (bitmap)
- last_path = path;
- else
+ auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(path);
+ if (bitmap_or_error.is_error()) {
last_path = String::empty();
+ } else {
+ last_path = path;
+ bitmap = bitmap_or_error.release_value();
+ }
}
};