mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
LibGUI: Tolerate Window::set_icon(nullptr)
Don't try to dereference a null icon. Instead just set a 16x16 empty bitmap as the window icon. This looks like the crash mentioned in #3817.
This commit is contained in:
parent
0341e3fde7
commit
0b746075d8
1 changed files with 4 additions and 2 deletions
|
@ -682,9 +682,11 @@ void Window::set_icon(const Gfx::Bitmap* icon)
|
||||||
if (m_icon == icon)
|
if (m_icon == icon)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_icon = create_shared_bitmap(Gfx::BitmapFormat::RGBA32, icon->size());
|
Gfx::IntSize icon_size = icon ? icon->size() : Gfx::IntSize(16, 16);
|
||||||
|
|
||||||
|
m_icon = create_shared_bitmap(Gfx::BitmapFormat::RGBA32, icon_size);
|
||||||
ASSERT(m_icon);
|
ASSERT(m_icon);
|
||||||
{
|
if (icon) {
|
||||||
Painter painter(*m_icon);
|
Painter painter(*m_icon);
|
||||||
painter.blit({ 0, 0 }, *icon, icon->rect());
|
painter.blit({ 0, 0 }, *icon, icon->rect());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue