1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:18:11 +00:00

GWindow: Fix crash when calling set_rect() repeatedly.

We throw away the backing store if the window rect changes size. Since the
resizing happens asynchronously at the mercy of the WindowServer, we might
end up in set_rect() again before gaining a new backing store. So there are
no guarantees that the back/front bitmaps exist here.
This commit is contained in:
Andreas Kling 2019-04-26 20:08:30 +02:00
parent 146aedc32c
commit 9ff36afeaa

View file

@ -144,9 +144,9 @@ void GWindow::set_rect(const Rect& a_rect)
request.window_id = m_window_id;
request.window.rect = a_rect;
GEventLoop::current().post_message_to_server(request);
if (m_back_bitmap->size() != a_rect.size())
if (m_back_bitmap && m_back_bitmap->size() != a_rect.size())
m_back_bitmap = nullptr;
if (m_front_bitmap->size() != a_rect.size())
if (m_front_bitmap && m_front_bitmap->size() != a_rect.size())
m_front_bitmap = nullptr;
if (m_main_widget)
m_main_widget->resize(a_rect.size());