[gtk/matthiasc/for-main: 1/2] inspector: Fix some criticals




commit b895360f49e494fb531d64958a16678f182cb5c6
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 9 09:08:24 2022 -0400

    inspector: Fix some criticals
    
    This is fallout from the recent porting to GtkColumnView.

 gtk/inspector/css-node-tree.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index f15eed3ca2..30651f5d65 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -188,19 +188,25 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorCssNodeTree, gtk_inspector_css_node_tree
 static void
 gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
                                       GtkCssNode              *node);
+static void
+gtk_inspector_css_node_tree_unset_node (GtkInspectorCssNodeTree *cnt);
 
 static void
 selection_changed (GtkSelectionModel       *model,
                    GParamSpec              *pspec,
                    GtkInspectorCssNodeTree *cnt)
 {
-  GtkTreeListRow *row;
-  GtkCssNode *node;
-
-  row = gtk_single_selection_get_selected_item (cnt->priv->selection_model);
-  node = gtk_tree_list_row_get_item (row);
+  if (gtk_single_selection_get_selected (cnt->priv->selection_model) != GTK_INVALID_LIST_POSITION)
+    {
+      GtkTreeListRow *row;
+      GtkCssNode *node;
 
-  gtk_inspector_css_node_tree_set_node (cnt, node);
+      row = gtk_single_selection_get_selected_item (cnt->priv->selection_model);
+      node = gtk_tree_list_row_get_item (row);
+      gtk_inspector_css_node_tree_set_node (cnt, node);
+    }
+  else
+    gtk_inspector_css_node_tree_unset_node (cnt);
 }
 
 static void
@@ -261,8 +267,6 @@ gtk_inspector_css_node_tree_finalize (GObject *object)
 
   gtk_inspector_css_node_tree_unset_node (cnt);
 
-  g_object_unref (cnt->priv->prop_model);
-
   G_OBJECT_CLASS (gtk_inspector_css_node_tree_parent_class)->finalize (object);
 }
 


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