1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 06:14:58 +00:00

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.
This commit is contained in:
MacDue 2022-05-13 23:56:33 +01:00 committed by Andreas Kling
parent 74695ce76e
commit 857a767ab4
2 changed files with 2 additions and 1 deletions

View file

@ -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);

View file

@ -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;