[gtk+] Fix life-cycle handling of treeview columns



commit 4f1d9452becc18301b561d4a6fc575cfb4137911
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Feb 21 22:31:16 2014 -0500

    Fix life-cycle handling of treeview columns
    
    gtk_tree_view_remove_column was first removing the column from
    its list, then call gtk_tree_view_column_unset_tree_view, which
    would then call gtk_container_remove to remove its button from
    the treeview. But the treeview remove implementation relied
    on the column being still in the list in order to recognize
    the button as 'special', so in effect the button was never
    properly removed and thus, leaked.
    
    Fix this by callling unset_tree_view before removing the
    column from the list.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724891

 gtk/gtktreeview.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 953f070..2e0aa5d 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -11923,6 +11923,11 @@ gtk_tree_view_remove_column (GtkTreeView       *tree_view,
 
   position = g_list_index (tree_view->priv->columns, column);
 
+  if (gtk_widget_get_realized (GTK_WIDGET (tree_view)))
+    _gtk_tree_view_column_unrealize_button (column);
+
+  _gtk_tree_view_column_unset_tree_view (column);
+
   tree_view->priv->columns = g_list_remove (tree_view->priv->columns, column);
   tree_view->priv->n_columns--;
 
@@ -11930,7 +11935,6 @@ gtk_tree_view_remove_column (GtkTreeView       *tree_view,
     {
       GList *list;
 
-      _gtk_tree_view_column_unrealize_button (column);
       for (list = tree_view->priv->columns; list; list = list->next)
        {
          GtkTreeViewColumn *tmp_column;
@@ -11948,7 +11952,6 @@ gtk_tree_view_remove_column (GtkTreeView       *tree_view,
     }
 
   _gtk_tree_view_reset_header_styles (tree_view);
-  _gtk_tree_view_column_unset_tree_view (column);
   _gtk_tree_view_accessible_remove_column (tree_view, column, position);
 
   g_object_unref (column);


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