LibGUI: Make a copy of source_rows before resizing it in sort_mapping()

This commit is contained in:
Vitaly Dyachkov 2022-02-16 18:00:45 +01:00 committed by Andreas Kling
parent 4f19deb13b
commit b2e6ba8d7f
Notes: sideshowbarker 2024-07-17 18:42:46 +09:00

View file

@ -163,6 +163,8 @@ ModelIndex SortingProxyModel::parent_index(ModelIndex const& proxy_index) const
void SortingProxyModel::sort_mapping(Mapping& mapping, int column, SortOrder sort_order)
{
auto old_source_rows = mapping.source_rows;
int row_count = source().row_count(mapping.source_parent);
mapping.source_rows.resize(row_count);
mapping.proxy_rows.resize(row_count);
@ -175,8 +177,6 @@ void SortingProxyModel::sort_mapping(Mapping& mapping, int column, SortOrder sor
return;
}
auto old_source_rows = mapping.source_rows;
for (int i = 0; i < row_count; ++i)
mapping.source_rows[i] = i;