From 9ff36afeaab7e583afd3de303bba5ded3b8a448e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 26 Apr 2019 20:08:30 +0200 Subject: [PATCH] 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. --- LibGUI/GWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index 13319204e0..36dbd2fe11 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -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());