diff options
author | MacDue <macdue@dueutil.tech> | 2022-05-13 23:56:33 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-05-18 19:05:18 +0200 |
commit | 857a767ab49b6813707b81d93fab81d524cca574 (patch) | |
tree | eb7e10987f03c720f21f263de0b4c892194517ae | |
parent | 74695ce76ea5f6b88d8cb166621edafd1abedb47 (diff) | |
download | serenity-857a767ab49b6813707b81d93fab81d524cca574.zip |
WindowServer: Fix crash when hovering over title buttons
This fixes a crash where if you switched to a theme that has hover
icons for title buttons, then back to a theme that does not. Then
when you next hover over the title buttons the window server would
crash.
This was due to the hover_bitmap multi-scale bitmap pointer being
non-null, but not containing any bitmaps, so hitting an assertion
when painting.
-rw-r--r-- | Userland/Services/WindowServer/Button.cpp | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/MultiScaleBitmaps.h | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Services/WindowServer/Button.cpp b/Userland/Services/WindowServer/Button.cpp index d6d9769ec5..bc73ff5383 100644 --- a/Userland/Services/WindowServer/Button.cpp +++ b/Userland/Services/WindowServer/Button.cpp @@ -39,7 +39,7 @@ void Button::paint(Screen& screen, Gfx::Painter& painter) painter.blit(icon_location, bitmap, bitmap.rect()); }; - if (m_icon.hover_bitmap && m_hovered) + if (m_hovered && m_icon.hover_bitmap && !m_icon.hover_bitmap->is_empty()) paint_icon(m_icon.hover_bitmap); else if (m_icon.bitmap) paint_icon(m_icon.bitmap); diff --git a/Userland/Services/WindowServer/MultiScaleBitmaps.h b/Userland/Services/WindowServer/MultiScaleBitmaps.h index 765efc58cc..47789bd284 100644 --- a/Userland/Services/WindowServer/MultiScaleBitmaps.h +++ b/Userland/Services/WindowServer/MultiScaleBitmaps.h @@ -24,6 +24,7 @@ public: Gfx::BitmapFormat format() const { return m_format; } bool load(StringView filename, StringView default_filename = {}); void add_bitmap(int scale_factor, NonnullRefPtr<Gfx::Bitmap>&&); + bool is_empty() const { return m_bitmaps.is_empty(); } private: MultiScaleBitmaps() = default; |