HackStudio: Correct DeclarationsModel::row_count() calculation

No indices contain other indices, so the row count is 0 if the index is
valid. This stops us infinitely recursing into non-existent indices.
This commit is contained in:
Sam Atkins 2024-01-25 14:15:50 +00:00 committed by Sam Atkins
parent 44033415bc
commit e72b14ef1d
Notes: sideshowbarker 2024-07-17 04:09:56 +09:00

View File

@ -38,7 +38,14 @@ public:
Filename,
__Column_Count,
};
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return m_declarations.size(); }
virtual int row_count(GUI::ModelIndex const& index = GUI::ModelIndex()) const override
{
if (!index.is_valid())
return m_declarations.size();
return 0;
}
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Column_Count; }
virtual GUI::Variant data(GUI::ModelIndex const& index, GUI::ModelRole role) const override;