diff options
author | Tomas Bzatek <[email protected]> | 2020-07-16 17:39:22 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-07-23 13:30:35 +0200 |
commit | 5f14b49e80d0e1195558803288a727084a4df33b (patch) | |
tree | 546acf8d2b4a79ff5a680e9fa2aecbf906d418f1 | |
parent | a3c1a007dcbe496d4e27f3cc93b428bbc4b54c8f (diff) | |
download | mate-panel-5f14b49e80d0e1195558803288a727084a4df33b.tar.bz2 mate-panel-5f14b49e80d0e1195558803288a727084a4df33b.tar.xz |
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.
-rw-r--r-- | mate-panel/panel-applet-frame.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/mate-panel/panel-applet-frame.c b/mate-panel/panel-applet-frame.c index a3aa92e6..e2204b38 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, |