summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/SortingProxyModel.cpp
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-08-08 10:01:19 +0000
committerAndreas Kling <kling@serenityos.org>2021-08-08 14:13:37 +0200
commit265e2832efe37aae95cad58c1b7157b793cd9e29 (patch)
tree1b9cb179f73fe90a071bd0cee6e6c895558d5976 /Userland/Libraries/LibGUI/SortingProxyModel.cpp
parent7ba321c91b883c5cd3f1c4b05bba7f53635c3007 (diff)
downloadserenity-265e2832efe37aae95cad58c1b7157b793cd9e29.zip
LibGUI: Resize the mapping rows during sort
SortingProxyModel always expected the source model to have the same number of rows as long as it has not been invalidated. Now that we have granular updates, this assumption is no longer true, and we need to resize the source/proxy_rows vectors to the new size. This is safe since the values in the vector are overwritten right afterwards.
Diffstat (limited to 'Userland/Libraries/LibGUI/SortingProxyModel.cpp')
-rw-r--r--Userland/Libraries/LibGUI/SortingProxyModel.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/SortingProxyModel.cpp b/Userland/Libraries/LibGUI/SortingProxyModel.cpp
index fd8a4dbb51..40174b45c0 100644
--- a/Userland/Libraries/LibGUI/SortingProxyModel.cpp
+++ b/Userland/Libraries/LibGUI/SortingProxyModel.cpp
@@ -175,6 +175,9 @@ void SortingProxyModel::sort_mapping(Mapping& mapping, int column, SortOrder sor
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);
+
for (int i = 0; i < row_count; ++i)
mapping.source_rows[i] = i;