[gtk/window-destroy: 8/16] filechooserdialog: Fix disposing



commit 9f886a878b2dbc2250e5c849504d47b5002f22b1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 9 15:19:39 2020 -0400

    filechooserdialog: Fix disposing
    
    We need to drop our widgetry in dispose to prevent
    leakage.

 gtk/gtkfilechooserdialog.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 61b9bf9b75..1eae65ae18 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -221,6 +221,7 @@ struct _GtkFileChooserDialogPrivate
   gboolean has_entry;
 };
 
+static void     gtk_file_chooser_dialog_dispose      (GObject               *object);
 static void     gtk_file_chooser_dialog_set_property (GObject               *object,
                                                       guint                  prop_id,
                                                       const GValue          *value,
@@ -262,6 +263,7 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
   GObjectClass *gobject_class = G_OBJECT_CLASS (class);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
+  gobject_class->dispose = gtk_file_chooser_dialog_dispose;
   gobject_class->set_property = gtk_file_chooser_dialog_set_property;
   gobject_class->get_property = gtk_file_chooser_dialog_get_property;
   gobject_class->notify = gtk_file_chooser_dialog_notify;
@@ -387,6 +389,16 @@ file_chooser_widget_response_requested (GtkWidget            *widget,
   priv->response_requested = FALSE;
 }
 
+static void
+gtk_file_chooser_dialog_dispose (GObject *object)
+{
+  GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG 
(object));
+
+  g_clear_pointer ((GtkWidget **)&priv->widget, gtk_widget_unparent);
+
+  G_OBJECT_CLASS (gtk_file_chooser_dialog_parent_class)->dispose (object);
+}
+
 static void
 gtk_file_chooser_dialog_set_property (GObject      *object,
                                       guint         prop_id,


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