From: Benjamin Otte Date: Mon, 23 Aug 2021 03:55:56 +0000 (+0200) Subject: fontbutton: Destroy dialog in unrealize() X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2^2~124^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d36b27cc3a6113712d7c754b53ef185e915a8120;p=gtk4.git fontbutton: Destroy dialog in unrealize() This way, we can be sure it's always using the right display. We can also be sure that it doesn't leak. --- diff --git a/gtk/gtkfontbutton.c b/gtk/gtkfontbutton.c index aad99d186b..fe125fd84d 100644 --- a/gtk/gtkfontbutton.c +++ b/gtk/gtkfontbutton.c @@ -461,6 +461,16 @@ gtk_font_button_activate (GtkFontButton *self) gtk_widget_activate (self->button); } +static void +gtk_font_button_unrealize (GtkWidget *widget) +{ + GtkFontButton *font_button = GTK_FONT_BUTTON (widget); + + g_clear_pointer ((GtkWindow **) &font_button->font_dialog, gtk_window_destroy); + + GTK_WIDGET_CLASS (gtk_font_button_parent_class)->unrealize (widget); +} + static void gtk_font_button_class_init (GtkFontButtonClass *klass) { @@ -476,6 +486,7 @@ gtk_font_button_class_init (GtkFontButtonClass *klass) widget_class->grab_focus = gtk_widget_grab_focus_child; widget_class->focus = gtk_widget_focus_child; + widget_class->unrealize = gtk_font_button_unrealize; klass->font_set = NULL; klass->activate = gtk_font_button_activate; @@ -628,9 +639,6 @@ gtk_font_button_finalize (GObject *object) { GtkFontButton *font_button = GTK_FONT_BUTTON (object); - if (font_button->font_dialog != NULL) - gtk_window_destroy (GTK_WINDOW (font_button->font_dialog)); - g_free (font_button->title); clear_font_data (font_button);