HackStudio: Fix crash when clicking unstaged files

In certain cases, an index might be invalid in the unstaged files view.
We must check if this index is valid before attempting to read the
index's data.
This commit is contained in:
Conor Byrne 2021-12-30 16:16:08 +00:00 committed by Andreas Kling
parent c0a3b1467c
commit 507ad1954f
Notes: sideshowbarker 2024-07-17 21:53:03 +09:00

View File

@ -45,6 +45,9 @@ GitWidget::GitWidget(const LexicalPath& repo_root)
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors());
m_unstaged_files->on_selection_change = [this] {
const auto& index = m_unstaged_files->selection().first();
if (!index.is_valid())
return;
const auto& selected = index.data().as_string();
show_diff(LexicalPath(selected));
};