summaryrefslogtreecommitdiff
path: root/gtk/gtklistbox.c
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2016-06-20 15:17:00 -0700
committerChristian Hergert <chergert@redhat.com>2016-06-20 18:51:42 -0700
commit3724592efb87567691d47e6f02a7cfb2dc014a3d (patch)
tree2b2ee40bb0d897c9e9f8f6b92b4a5bc361cb7a39 /gtk/gtklistbox.c
parent49bd5a97ce9a4bfd1267133c13b1f8883b7e76b9 (diff)
downloadgtk+-3724592efb87567691d47e6f02a7cfb2dc014a3d.tar.gz
listbox: short-circuit if no sort function is set
do_sort will crash if sort_func is not defined. Instead of adding a check there in the hot path, just check for sort_func before invalidating the sort of the underlying GSequence.
Diffstat (limited to 'gtk/gtklistbox.c')
-rw-r--r--gtk/gtklistbox.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 91c08e361e..17f19072ec 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -1280,6 +1280,9 @@ gtk_list_box_invalidate_sort (GtkListBox *box)
g_return_if_fail (GTK_IS_LIST_BOX (box));
+ if (priv->sort_func == NULL)
+ return;
+
g_sequence_sort (priv->children, (GCompareDataFunc)do_sort, box);
g_sequence_foreach (priv->children, gtk_list_box_css_node_foreach, &previous);