From 856e2c56e023f40c6f69edebe1c42c5243882ecc Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Wed, 15 Nov 2023 13:34:17 -0500 Subject: [PATCH] display module: Fix some memory leaks. --- panels/display/cc-display-arrangement.c | 1 + panels/display/cc-display-panel.c | 8 +++++++- panels/display/cc-display-settings.c | 3 +++ shell/cc-shell-item-view.c | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/panels/display/cc-display-arrangement.c b/panels/display/cc-display-arrangement.c index fa026ae..ca0ace9 100644 --- a/panels/display/cc-display-arrangement.c +++ b/panels/display/cc-display-arrangement.c @@ -706,6 +706,7 @@ cc_display_arrangement_draw (GtkWidget *widget, gtk_style_context_get (context, state, "font", &font, NULL); layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), number_str); pango_layout_set_font_description (layout, font); + pango_font_description_free (font); pango_layout_get_extents (layout, NULL, &extents); h = (extents.height - extents.y) / PANGO_SCALE; diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c index b927a73..5a513b4 100644 --- a/panels/display/cc-display-panel.c +++ b/panels/display/cc-display-panel.c @@ -480,6 +480,9 @@ cc_display_panel_dispose (GObject *object) g_clear_object (&self->labeler); g_clear_pointer (&self->palette, g_free); + g_clear_object (&self->output_selection_list); + g_clear_object (&self->builder); + g_signal_handlers_disconnect_by_func (self, widget_visible_changed, NULL); G_OBJECT_CLASS (cc_display_panel_parent_class)->dispose (object); @@ -722,9 +725,10 @@ rebuild_ui (CcDisplayPanel *panel) pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 20, 20); - gchar *color_string = get_color_string_for_output (output); + gchar *color_string = get_color_string_for_output (panel, index); gdk_rgba_parse (&color, color_string); + g_free (color_string); pixel = pixel + ((int) (color.red * 255) << 24); pixel = pixel + ((int) (color.green * 255) << 16); @@ -751,6 +755,8 @@ rebuild_ui (CcDisplayPanel *panel) 2, pixbuf, -1); + g_object_unref (pixbuf); + if (!cc_display_monitor_is_usable (output)) continue; diff --git a/panels/display/cc-display-settings.c b/panels/display/cc-display-settings.c index cf3b029..18cc2cb 100644 --- a/panels/display/cc-display-settings.c +++ b/panels/display/cc-display-settings.c @@ -414,6 +414,8 @@ cc_display_settings_rebuild_ui (CcDisplaySettings *self) 1, l->data, -1); + g_free (resolution_string); + if (current_mode == l->data) { gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->resolution_combo), &iter); @@ -678,6 +680,7 @@ cc_display_settings_finalize (GObject *object) g_clear_object (&self->orientation_list); g_clear_object (&self->refresh_rate_list); g_clear_object (&self->resolution_list); + g_clear_object (&self->builder); if (self->idle_udpate_id) g_source_remove (self->idle_udpate_id); diff --git a/shell/cc-shell-item-view.c b/shell/cc-shell-item-view.c index dffdbc7..2dd9a36 100644 --- a/shell/cc-shell-item-view.c +++ b/shell/cc-shell-item-view.c @@ -166,6 +166,8 @@ cc_shell_item_view_update_cells (CcShellItemView *view) break; } } + + g_list_free (cells); } static void