shared/cairo-util: Hold onto our pattern reference until we're done

This doesn't actually fix a bug - cairo refcounts this. But I
really don't like the look of code that drops a reference then
continues to use it.

While we're here, set a different pattern when we're done so the
one we allocated loses its last reference.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
dev
Derek Foreman 3 years ago
parent 8b654c47eb
commit 2afb812d1e
  1. 4
      shared/cairo-util.c

@ -275,7 +275,6 @@ tile_source(cairo_t *cr, cairo_surface_t *surface,
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST);
cairo_set_source(cr, pattern);
cairo_pattern_destroy(pattern);
for (i = 0; i < 4; i++) {
fx = i & 1;
@ -328,6 +327,9 @@ tile_source(cairo_t *cr, cairo_surface_t *surface,
cairo_rectangle(cr, x + width - margin, y + top_margin,
margin, height - margin - top_margin);
cairo_fill(cr);
cairo_pattern_destroy(pattern);
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
}
void

Loading…
Cancel
Save