From fe7d801dd97c5e439a996906cda37da124d69e0f Mon Sep 17 00:00:00 2001 From: Arif Orhun Uzun Date: Mon, 7 Mar 2022 00:01:29 +0300 Subject: [PATCH] SpaceAnalyzer: Fix the crash caused by double click With #12480, Breadcrumbbar's on_focus_change() uses on_click(). In SpaceAnalyzer, double clicking triggers the TreeWidgetMap's on_path_change(), which triggers Breadcrumbbar's on_focus_change(), which also triggers the TreeWidgetMap's on_path_change() again. This resulted in use-after-free of Breadcrumbbar, thus resulted in the crash. Not updating the TreeWidgetMap's viewpoint recursively solves the issue. --- Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp index df13cc346f..5409b358ff 100644 --- a/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp +++ b/Userland/Applications/SpaceAnalyzer/TreeMapWidget.cpp @@ -341,6 +341,8 @@ void TreeMapWidget::set_tree(RefPtr tree) void TreeMapWidget::set_viewpoint(size_t viewpoint) { + if (m_viewpoint == viewpoint) + return; if (viewpoint > m_path.size()) viewpoint = m_path.size(); m_viewpoint = viewpoint;