[gtk/wip/otte/inspector: 2/10] fontbutton: Destroy dialog in unrealize()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/inspector: 2/10] fontbutton: Destroy dialog in unrealize()
- Date: Mon, 23 Aug 2021 05:35:23 +0000 (UTC)
commit 481125ac01a852c16ccca4b807bdd7b09ce94ada
Author: Benjamin Otte <otte redhat com>
Date: Mon Aug 23 05:55:56 2021 +0200
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.
gtk/gtkfontbutton.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]