[gtk/gtk3-a11y-leak: 2/2] a11y: Plug a memory leak with treeviews




commit 21f8098261486417db371b202bc0494c12017468
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 11 08:55:48 2021 -0400

    a11y: Plug a memory leak with treeviews
    
    We need to explicitly remove the children from
    a GtkContainerCellAccessible, since they otherwise
    keep the parent alive.
    
    Fixes: #3981

 gtk/a11y/gtktreeviewaccessible.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gtk/a11y/gtktreeviewaccessible.c b/gtk/a11y/gtktreeviewaccessible.c
index adad462064..c1a2097a1e 100644
--- a/gtk/a11y/gtktreeviewaccessible.c
+++ b/gtk/a11y/gtktreeviewaccessible.c
@@ -104,6 +104,17 @@ static void
 cell_info_free (GtkTreeViewAccessibleCellInfo *cell_info)
 {
   gtk_accessible_set_widget (GTK_ACCESSIBLE (cell_info->cell), NULL);
+  if (GTK_IS_CONTAINER_CELL_ACCESSIBLE (cell_info->cell))
+    {
+      GList *children;
+
+      while ((children = gtk_container_cell_accessible_get_children (GTK_CONTAINER_CELL_ACCESSIBLE 
(cell_info->cell))) != NULL)
+        {
+          GtkCellAccessible *child = children->data;
+          gtk_container_cell_accessible_remove_child (GTK_CONTAINER_CELL_ACCESSIBLE (cell_info->cell), 
child);
+        }
+    }
+
   g_object_unref (cell_info->cell);
 
   g_free (cell_info);


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