[gtk/stack-fixes] stack sidebar: Handle unselection robustly



commit 105cdef2012a1d171bb887f8bf8917f043833571
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 9 20:11:01 2019 -0500

    stack sidebar: Handle unselection robustly
    
    When item are removed, we sometimes get ::selection-changed
    notification for an item that is already gone. If this happens,
    the row is already removed anyway, so we can just ignore it.

 gtk/gtkstacksidebar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkstacksidebar.c b/gtk/gtkstacksidebar.c
index 77fabd66b2..84e571cde4 100644
--- a/gtk/gtkstacksidebar.c
+++ b/gtk/gtkstacksidebar.c
@@ -342,8 +342,10 @@ selection_changed_cb (GtkSelectionModel *model,
 {
   GtkStackSidebarPrivate *priv = gtk_stack_sidebar_get_instance_private (sidebar);
   guint i;
+  guint end;
 
-  for (i = position; i < position + n_items; i++)
+  end = MIN (position + n_items, g_list_model_get_n_items (G_LIST_MODEL (model));
+  for (i = position; i < end; i++)
     {
       GtkWidget *child;
       GtkWidget *row;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]