1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

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

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));
};