diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-05-09 14:10:38 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-11 12:19:39 -0400 |
commit | b6bfeb786fe55212bbe8cf9df5f8f39051f1bf18 (patch) | |
tree | 7b8253827ab4887148db9b90ea2fb5874e4d9d17 /gtk | |
parent | 573b20a8f88e8dd2a622fde09201fd2543706ee4 (diff) | |
download | gtk+-b6bfeb786fe55212bbe8cf9df5f8f39051f1bf18.tar.gz |
fontchooserdialog: Fix disposing
We need to drop our widgetry in dispose to prevent
leakage.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkfontchooserdialog.c | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/gtk/gtkfontchooserdialog.c b/gtk/gtkfontchooserdialog.c index 11d17c9668..9083806f89 100644 --- a/gtk/gtkfontchooserdialog.c +++ b/gtk/gtkfontchooserdialog.c @@ -48,7 +48,6 @@ struct _GtkFontChooserDialog GtkDialog parent_instance; GtkWidget *fontchooser; - GtkWidget *select_button; GtkWidget *cancel_button; GtkWidget *tweak_button; @@ -201,11 +200,48 @@ gtk_font_chooser_dialog_map (GtkWidget *widget) } static void +update_button (GtkFontChooserDialog *dialog) +{ + PangoFontDescription *desc; + + desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (dialog->fontchooser)); + + gtk_widget_set_sensitive (dialog->select_button, desc != NULL); + + if (desc) + pango_font_description_free (desc); +} + +static void +gtk_font_chooser_dialog_dispose (GObject *object) +{ + GtkFontChooserDialog *dialog = GTK_FONT_CHOOSER_DIALOG (object); + + if (dialog->fontchooser) + { + g_signal_handlers_disconnect_by_func (dialog->fontchooser, + update_button, + dialog); + g_signal_handlers_disconnect_by_func (dialog->fontchooser, + update_tweak_button, + dialog); + } + + g_clear_pointer (&dialog->select_button, gtk_widget_unparent); + g_clear_pointer (&dialog->cancel_button, gtk_widget_unparent); + g_clear_pointer (&dialog->tweak_button, gtk_widget_unparent); + g_clear_pointer (&dialog->fontchooser, gtk_widget_unparent); + + G_OBJECT_CLASS (gtk_font_chooser_dialog_parent_class)->dispose (object); +} + +static void gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + gobject_class->dispose = gtk_font_chooser_dialog_dispose; gobject_class->get_property = gtk_font_chooser_dialog_get_property; gobject_class->set_property = gtk_font_chooser_dialog_set_property; @@ -226,20 +262,6 @@ gtk_font_chooser_dialog_class_init (GtkFontChooserDialogClass *klass) } static void -update_button (GtkFontChooserDialog *dialog) -{ - PangoFontDescription *desc; - - desc = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (dialog->fontchooser)); - - gtk_widget_set_sensitive (dialog->select_button, desc != NULL); - - if (desc) - pango_font_description_free (desc); -} - - -static void gtk_font_chooser_dialog_init (GtkFontChooserDialog *dialog) { gtk_widget_init_template (GTK_WIDGET (dialog)); |