[gtk/wip/otte/listview] single selection: Be robust



commit 75a1bafcc0090770dc16d93bff7f083816565d1b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 6 10:46:08 2019 -0500

    single selection: Be robust
    
    Make gtk_single_selection_set_selected work without
    a model. It gets called a internally, and that might
    just happen when there's no model.

 gtk/gtksingleselection.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtksingleselection.c b/gtk/gtksingleselection.c
index 756d59a5a3..3d4227bd16 100644
--- a/gtk/gtksingleselection.c
+++ b/gtk/gtksingleselection.c
@@ -435,7 +435,7 @@ void
 gtk_single_selection_set_selected (GtkSingleSelection *self,
                                    guint               position)
 {
-  gpointer new_selected;
+  gpointer new_selected = NULL;
   guint old_position;
 
   g_return_if_fail (GTK_IS_SINGLE_SELECTION (self));
@@ -443,7 +443,9 @@ gtk_single_selection_set_selected (GtkSingleSelection *self,
   if (self->selected == position)
     return;
 
-  new_selected = g_list_model_get_item (self->model, position);
+  if (self->model)
+    new_selected = g_list_model_get_item (self->model, position);
+
   if (new_selected == NULL)
     position = GTK_INVALID_LIST_POSITION;
 


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