sortlistmodel: Fix handling of section sort keys
authorMatthias Clasen <mclasen@redhat.com>
Sat, 27 May 2023 21:26:39 +0000 (17:26 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 27 May 2023 21:27:19 +0000 (17:27 -0400)
    When the section sorter changes, we need to update
    the keys, otherwise the sorter will continue to report
    the old sections.

    This code is currently a bit suboptimal, since the
    creation of sort keys and section sort keys are
    muddled together.

Fixes: #5854
gtk/gtksortlistmodel.c

index 50add242f0ad8a275182234c34df668cdb6df370..becfec012eea9d49275aef64478ee4475bb10acd 100644 (file)
@@ -912,6 +912,12 @@ gtk_sort_list_model_sorter_changed_cb (GtkSorter        *sorter,
             }
         }
 
+      if (self->section_sorter)
+        {
+          gtk_sort_keys_unref (self->section_sort_keys);
+          self->section_sort_keys = gtk_sorter_get_keys (self->section_sorter);
+        }
+
       if (gtk_sort_list_model_start_sorting (self, NULL))
         pos = n_items = 0;
       else