From 0eb1eacb64d3f32343a72fb2c31fdd60dedb9674 Mon Sep 17 00:00:00 2001 From: Matthijs Velsink Date: Fri, 2 Feb 2024 01:08:17 +0100 Subject: [PATCH] system/about: Do not leak CcSystemDetailsWindow The window should be destroyed and unreferenced when the About page is disposed to prevent leaking it. We need to take the reference in order to not repeat #2823, since the AdwWindow is initially floating. --- panels/system/about/cc-about-page.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/panels/system/about/cc-about-page.c b/panels/system/about/cc-about-page.c index 89471e69d..61a643f0b 100644 --- a/panels/system/about/cc-about-page.c +++ b/panels/system/about/cc-about-page.c @@ -119,7 +119,10 @@ cc_about_page_open_system_details (CcAboutPage *self) GtkNative *parent; if (!self->system_details_window) - self->system_details_window = GTK_WINDOW (cc_system_details_window_new ()); + { + self->system_details_window = GTK_WINDOW (cc_system_details_window_new ()); + g_object_ref_sink (self->system_details_window); + } parent = gtk_widget_get_native (GTK_WIDGET (self)); gtk_window_set_transient_for (self->system_details_window, GTK_WINDOW (parent)); @@ -203,11 +206,26 @@ setup_os_logo (CcAboutPage *self) #endif } +static void +cc_about_page_dispose (GObject *object) +{ + CcAboutPage *self = CC_ABOUT_PAGE (object); + + if (self->system_details_window) + gtk_window_destroy (self->system_details_window); + g_clear_object (&self->system_details_window); + + G_OBJECT_CLASS (cc_about_page_parent_class)->dispose (object); +} + static void cc_about_page_class_init (CcAboutPageClass *klass) { + GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + object_class->dispose = cc_about_page_dispose; + g_type_ensure (CC_TYPE_HOSTNAME_ENTRY); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/system/about/cc-about-page.ui");