TreeView: Don't try to move cursor with invalid index

When clicking on the TreeView in profiler without selecting a node and
then pressing up or pgup, cursor_index was in an invalid state. Instead
select the first node in the index.
This commit is contained in:
Marcus Nilsson 2021-06-03 19:15:26 +02:00 committed by Andreas Kling
parent f295ac3c0b
commit 94551149d1
Notes: sideshowbarker 2024-07-18 16:51:36 +09:00

View file

@ -480,6 +480,9 @@ void TreeView::move_cursor(CursorMovement movement, SelectionUpdate selection_up
{
auto& model = *this->model();
if (!cursor_index().is_valid())
set_cursor(model.index(0, model.tree_column(), cursor_index()), SelectionUpdate::Set);
auto find_last_index_in_tree = [&](const ModelIndex tree_index) -> ModelIndex {
auto last_index = tree_index;
size_t row_count = model.row_count(last_index);