From 611733af0d94bfb48893e7ff8a901f0900eab7fb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 13 Jan 2022 15:47:28 +0100 Subject: [PATCH] WindowServer: Don't try to flash menubar in deleted windows Capture the window weakly when setting up the menubar flash timer. --- Userland/Services/WindowServer/ClientConnection.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Services/WindowServer/ClientConnection.cpp b/Userland/Services/WindowServer/ClientConnection.cpp index 33f191238f..b697649ddc 100644 --- a/Userland/Services/WindowServer/ClientConnection.cpp +++ b/Userland/Services/WindowServer/ClientConnection.cpp @@ -216,9 +216,11 @@ void ClientConnection::flash_menubar_menu(i32 window_id, i32 menu_id) m_flashed_menu_timer->stop(); } - m_flashed_menu_timer = Core::Timer::create_single_shot(75, [&window] { - window.menubar().flash_menu(nullptr); - window.frame().invalidate_menubar(); + m_flashed_menu_timer = Core::Timer::create_single_shot(75, [weak_window = window.make_weak_ptr()]() mutable { + if (!weak_window) + return; + weak_window->menubar().flash_menu(nullptr); + weak_window->frame().invalidate_menubar(); }); m_flashed_menu_timer->start(); } else if (m_flashed_menu_timer) {