summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <[email protected]>2020-07-16 17:39:22 +0200
committerraveit65 <[email protected]>2020-07-23 13:32:13 +0200
commitc77edcc25ef044317d689ad3c702645e371bee62 (patch)
tree5b06effc2c8010f0fa1dc0ade92be8779f797a5c
parentf2f0d36c6e11023f438ec3c1e78f69610b8ee85c (diff)
downloadmate-panel-c77edcc25ef044317d689ad3c702645e371bee62.tar.bz2
mate-panel-c77edcc25ef044317d689ad3c702645e371bee62.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.c40
1 files 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,