From c77edcc25ef044317d689ad3c702645e371bee62 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 16 Jul 2020 17:39:22 +0200 Subject: panel-applet-frame: Fix leaking bg_pattern Also acquire it only when needed. This fixes a leak for me when switching workspaces back and forth. --- mate-panel/panel-applet-frame.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/mate-panel/panel-applet-frame.c b/mate-panel/panel-applet-frame.c index a31f26a4..e8c1ca89 100644 --- a/mate-panel/panel-applet-frame.c +++ b/mate-panel/panel-applet-frame.c @@ -102,7 +102,6 @@ mate_panel_applet_frame_draw (GtkWidget *widget, MatePanelAppletFrame *frame = MATE_PANEL_APPLET_FRAME (widget); GtkStyleContext *context; GtkStateFlags state; - cairo_pattern_t *bg_pattern; PanelBackground *background; if (GTK_WIDGET_CLASS (mate_panel_applet_frame_parent_class)->draw) @@ -118,25 +117,28 @@ mate_panel_applet_frame_draw (GtkWidget *widget, cairo_save (cr); - /* Set the pattern transform so as to correctly render a patterned - * background with the handle */ - gtk_style_context_get (context, state, - "background-image", &bg_pattern, - NULL); - background = &frame->priv->panel->toplevel->background; - if (bg_pattern && (background->type == PANEL_BACK_IMAGE || - (background->type == PANEL_BACK_COLOR && background->has_alpha))) { - cairo_matrix_t ptm; - - cairo_matrix_init_translate (&ptm, - frame->priv->handle_rect.x, - frame->priv->handle_rect.y); - cairo_matrix_scale (&ptm, - frame->priv->handle_rect.width, - frame->priv->handle_rect.height); - cairo_pattern_set_matrix (bg_pattern, &ptm); - cairo_pattern_destroy (bg_pattern); + if (background->type == PANEL_BACK_IMAGE || + (background->type == PANEL_BACK_COLOR && background->has_alpha)) { + cairo_pattern_t *bg_pattern; + + /* Set the pattern transform so as to correctly render a patterned + * background with the handle */ + gtk_style_context_get (context, state, + "background-image", &bg_pattern, + NULL); + if (bg_pattern) { + cairo_matrix_t ptm; + + cairo_matrix_init_translate (&ptm, + frame->priv->handle_rect.x, + frame->priv->handle_rect.y); + cairo_matrix_scale (&ptm, + frame->priv->handle_rect.width, + frame->priv->handle_rect.height); + cairo_pattern_set_matrix (bg_pattern, &ptm); + cairo_pattern_destroy (bg_pattern); + } } cairo_rectangle (cr, -- cgit v1.2.1