Blame SOURCES/gtk-3.22.20-fix-treeview-refcount.patch

c99098
From d4f62b44d47e3dddfb57add4f1f76cab0297584d Mon Sep 17 00:00:00 2001
c99098
From: Matthias Clasen <mclasen@redhat.com>
c99098
Date: Fri, 11 Jun 2021 08:53:46 -0400
c99098
Subject: [PATCH 1/2] a11y: Fix ref counting in tree views
c99098
c99098
GtkContainerCellAccessible wasn't unsetting accessible
c99098
parents. Fix that.
c99098
c99098
By itself, this doesn't help for freeing a memory leak,
c99098
since AtkObject keeps a ref on its parent, so we never
c99098
free the GtkContainerCellAccessible as long as it has children.
c99098
---
c99098
 gtk/a11y/gtkcontainercellaccessible.c | 10 +++++++++-
c99098
 1 file changed, 9 insertions(+), 1 deletion(-)
c99098
c99098
diff --git a/gtk/a11y/gtkcontainercellaccessible.c b/gtk/a11y/gtkcontainercellaccessible.c
c99098
index a756e3cadf..a40446fb47 100644
c99098
--- a/gtk/a11y/gtkcontainercellaccessible.c
c99098
+++ b/gtk/a11y/gtkcontainercellaccessible.c
c99098
@@ -30,12 +30,19 @@ struct _GtkContainerCellAccessiblePrivate
c99098
 G_DEFINE_TYPE_WITH_PRIVATE (GtkContainerCellAccessible, gtk_container_cell_accessible, GTK_TYPE_CELL_ACCESSIBLE)
c99098
 
c99098
 
c99098
+static void
c99098
+unset_child (gpointer child)
c99098
+{
c99098
+  atk_object_set_parent (ATK_OBJECT (child), NULL);
c99098
+  g_object_unref (child);
c99098
+}
c99098
+
c99098
 static void
c99098
 gtk_container_cell_accessible_finalize (GObject *obj)
c99098
 {
c99098
   GtkContainerCellAccessible *container = GTK_CONTAINER_CELL_ACCESSIBLE (obj);
c99098
 
c99098
-  g_list_free_full (container->priv->children, g_object_unref);
c99098
+  g_list_free_full (container->priv->children, unset_child);
c99098
 
c99098
   G_OBJECT_CLASS (gtk_container_cell_accessible_parent_class)->finalize (obj);
c99098
 }
c99098
@@ -157,6 +164,7 @@ gtk_container_cell_accessible_remove_child (GtkContainerCellAccessible *containe
c99098
   g_return_if_fail (GTK_IS_CELL_ACCESSIBLE (child));
c99098
   g_return_if_fail (container->priv->n_children > 0);
c99098
 
c99098
+  atk_object_set_parent (ATK_OBJECT (child), NULL);
c99098
   container->priv->children = g_list_remove (container->priv->children, child);
c99098
   container->priv->n_children--;
c99098
 
c99098
-- 
c99098
GitLab
c99098
c99098
c99098
From 21f8098261486417db371b202bc0494c12017468 Mon Sep 17 00:00:00 2001
c99098
From: Matthias Clasen <mclasen@redhat.com>
c99098
Date: Fri, 11 Jun 2021 08:55:48 -0400
c99098
Subject: [PATCH 2/2] a11y: Plug a memory leak with treeviews
c99098
c99098
We need to explicitly remove the children from
c99098
a GtkContainerCellAccessible, since they otherwise
c99098
keep the parent alive.
c99098
c99098
Fixes: #3981
c99098
---
c99098
 gtk/a11y/gtktreeviewaccessible.c | 11 +++++++++++
c99098
 1 file changed, 11 insertions(+)
c99098
c99098
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
c99098
index adad462064..c1a2097a1e 100644
c99098
--- a/gtk/a11y/gtktreeviewaccessible.c
c99098
+++ b/gtk/a11y/gtktreeviewaccessible.c
c99098
@@ -104,6 +104,17 @@ static void
c99098
 cell_info_free (GtkTreeViewAccessibleCellInfo *cell_info)
c99098
 {
c99098
   gtk_accessible_set_widget (GTK_ACCESSIBLE (cell_info->cell), NULL);
c99098
+  if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell_info->cell))
c99098
+    {
c99098
+      GList *children;
c99098
+
c99098
+      while ((children = gtk_container_cell_accessible_get_children (GTK_CONTAINER_CELL_ACCESSIBLE (cell_info->cell))) != NULL)
c99098
+        {
c99098
+          GtkCellAccessible *child = children->data;
c99098
+          gtk_container_cell_accessible_remove_child (GTK_CONTAINER_CELL_ACCESSIBLE (cell_info->cell), child);
c99098
+        }
c99098
+    }
c99098
+
c99098
   g_object_unref (cell_info->cell);
c99098
 
c99098
   g_free (cell_info);
c99098
-- 
c99098
GitLab
c99098