mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-14 18:30:38 +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
Notes:
sideshowbarker
2024-07-19 07:54:58 +09:00
Author: https://github.com/xTibor Commit: https://github.com/SerenityOS/serenity/commit/192513ec332 Pull-request: https://github.com/SerenityOS/serenity/pull/1635
1 changed files with 6 additions and 0 deletions
|
@ -49,6 +49,9 @@ void QSWidget::set_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)
|
|||
|
||||
void QSWidget::relayout()
|
||||
{
|
||||
if (m_bitmap.is_null())
|
||||
return;
|
||||
|
||||
Gfx::Size new_size;
|
||||
float scale_factor = (float)m_scale / 100.0f;
|
||||
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)
|
||||
{
|
||||
if (m_bitmap.is_null())
|
||||
return;
|
||||
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
|
|
Loading…
Reference in a new issue