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

SpaceAnalyzer: Fix the crash caused by using arrow keys

Previously, SpaceAnalyzer set focus on the selected BreadcrumbButton.
Using arrow keys triggered the keydown_event of the AbstractButton,
which later on caused a Function object to be deleted while it is still
being used.

This change sets the focus on TreeMapWidget and adds an event handler
to TreeMapWidget for keydown events.

Fixes #13254.
This commit is contained in:
Arif Orhun Uzun 2022-03-30 22:44:00 +03:00 committed by Andreas Kling
parent 51df97e799
commit eb34015748
3 changed files with 11 additions and 0 deletions

View file

@ -306,6 +306,14 @@ void TreeMapWidget::doubleclick_event(GUI::MouseEvent& event)
}
}
void TreeMapWidget::keydown_event(GUI::KeyEvent& event)
{
if (event.key() == KeyCode::Key_Left)
set_viewpoint(m_viewpoint == 0 ? m_path.size() : m_viewpoint - 1);
else if (event.key() == KeyCode::Key_Right)
set_viewpoint(m_viewpoint == m_path.size() ? 0 : m_viewpoint + 1);
}
void TreeMapWidget::mousewheel_event(GUI::MouseEvent& event)
{
int delta = event.wheel_delta_y();