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

Help: Don't defer tree view selection updates

It is unsafe to defer this selection update, because ::open_url itself
is called when users make selection updates, creating a race.

This fixes and infinite selection change loop one could easily reproduce
by holding an up or down arrow key in the tree view while clicking on a
tree view item a couple of times.
This commit is contained in:
Mathis Wiehl 2023-03-05 17:35:09 +01:00 committed by Andreas Kling
parent 4797fad91c
commit f276e70ac9

View file

@ -246,8 +246,7 @@ void MainWidget::open_url(URL const& url)
m_web_view->load(url);
m_web_view->scroll_to_top();
GUI::Application::the()->deferred_invoke([&, path = url.path()] {
auto browse_view_index = m_manual_model->index_from_path(path);
auto browse_view_index = m_manual_model->index_from_path(url.path());
if (browse_view_index.has_value()) {
if (browse_view_index.value() != m_browse_view->selection_start_index()) {
m_browse_view->expand_all_parents_of(browse_view_index.value());
@ -263,7 +262,6 @@ void MainWidget::open_url(URL const& url)
} else {
window()->set_title("Help");
}
});
}
}