From 2dfad2b0d1cad454c4b68625be1e169023aaaed4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 20 Jul 2015 11:11:00 -0400 Subject: [PATCH] file chooser: Memory handling fixes I forgot to clean up the long press gesture, and in additon, creating the rename popover from the ui template was causing the tree view to not be disposed when the file chooser goes away. Work around this by manually unsetting the relative-to widget of the popover in dispose. --- gtk/gtkfilechooserwidget.c | 16 +++++++--------- gtk/ui/gtkfilechooserwidget.ui | 1 - 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 2ddd1605b9..cafb5ab418 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -649,7 +649,6 @@ gtk_file_chooser_widget_finalize (GObject *object) { GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (object); GtkFileChooserWidgetPrivate *priv = impl->priv; - GSList *l; if (priv->location_changed_id > 0) g_source_remove (priv->location_changed_id); @@ -658,14 +657,7 @@ gtk_file_chooser_widget_finalize (GObject *object) g_free (priv->browse_files_last_selected_name); - for (l = priv->filters; l; l = l->next) - { - GtkFileFilter *filter; - - filter = GTK_FILE_FILTER (l->data); - g_object_unref (filter); - } - g_slist_free (priv->filters); + g_slist_free_full (priv->filters, g_object_unref); if (priv->current_filter) g_object_unref (priv->current_filter); @@ -3526,6 +3518,9 @@ gtk_file_chooser_widget_dispose (GObject *object) cancel_all_operations (impl); + if (priv->rename_file_popover) + gtk_popover_set_relative_to (GTK_POPOVER (priv->rename_file_popover), NULL); + if (priv->browse_files_popover) { gtk_widget_destroy (priv->browse_files_popover); @@ -3552,6 +3547,8 @@ gtk_file_chooser_widget_dispose (GObject *object) priv->external_entry = NULL; } + g_clear_object (&priv->long_press_gesture); + G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->dispose (object); } @@ -8452,6 +8449,7 @@ post_process_ui (GtkFileChooserWidget *impl) gtk_popover_set_default_widget (GTK_POPOVER (impl->priv->new_folder_popover), impl->priv->new_folder_create_button); gtk_popover_set_default_widget (GTK_POPOVER (impl->priv->rename_file_popover), impl->priv->rename_file_rename_button); + gtk_popover_set_relative_to (GTK_POPOVER (impl->priv->rename_file_popover), impl->priv->browse_files_tree_view); add_actions (impl); } diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui index 9718ce581b..e86c374426 100644 --- a/gtk/ui/gtkfilechooserwidget.ui +++ b/gtk/ui/gtkfilechooserwidget.ui @@ -467,7 +467,6 @@ - browse_files_tree_view bottom