mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
QuickShow: Fix crash on startup
QSWidget::relayout get triggered before setting a bitmap to display while setting the widget as the main widget of the window. I've added a null check to the paint event too to make sure the widget works with no bitmap set.
This commit is contained in:
parent
4e54d0ff21
commit
192513ec33
1 changed files with 6 additions and 0 deletions
|
@ -49,6 +49,9 @@ void QSWidget::set_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)
|
||||||
|
|
||||||
void QSWidget::relayout()
|
void QSWidget::relayout()
|
||||||
{
|
{
|
||||||
|
if (m_bitmap.is_null())
|
||||||
|
return;
|
||||||
|
|
||||||
Gfx::Size new_size;
|
Gfx::Size new_size;
|
||||||
float scale_factor = (float)m_scale / 100.0f;
|
float scale_factor = (float)m_scale / 100.0f;
|
||||||
new_size.set_width(m_bitmap->width() * scale_factor);
|
new_size.set_width(m_bitmap->width() * scale_factor);
|
||||||
|
@ -65,6 +68,9 @@ void QSWidget::resize_event(GUI::ResizeEvent& event)
|
||||||
|
|
||||||
void QSWidget::paint_event(GUI::PaintEvent& event)
|
void QSWidget::paint_event(GUI::PaintEvent& event)
|
||||||
{
|
{
|
||||||
|
if (m_bitmap.is_null())
|
||||||
|
return;
|
||||||
|
|
||||||
GUI::Painter painter(*this);
|
GUI::Painter painter(*this);
|
||||||
painter.add_clip_rect(event.rect());
|
painter.add_clip_rect(event.rect());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue