HackStudio: Don't vend invalid indices from SearchResultsModel

This fixes an assertion when clicking in the "find in files" search
results table when there were no matches.
This commit is contained in:
Andreas Kling 2020-12-10 18:35:59 +01:00
parent ebbae015ef
commit e9280cba13

View file

@ -96,7 +96,14 @@ public:
}
virtual void update() override { }
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); }
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override
{
if (row < 0 || row >= (int)m_matches.size())
return {};
if (column < 0 || column >= Column::__Count)
return {};
return create_index(row, column, &m_matches.at(row));
}
private:
Vector<Match> m_matches;