GitLab will be down for maintenance this Sunday 13th June, from approx 7-11am UTC. This is for a PostgreSQL migration. See the tracker issue for more informations.

Commit 16769357 authored by Mathieu Duponchelle's avatar Mathieu Duponchelle 🐸 Committed by Tim-Philipp Müller
Browse files

raster-source: fix when builddir != srcdir

When the build dir is different from the source dir,
"png.png" is not a valid path. As we can't dispose of
an allocated filename, we add an atexit handler.
parent 4645ecf3
......@@ -34,6 +34,8 @@
#define WIDTH 200
#define HEIGHT 80
static char *png_filename = NULL;
/* Lazy way of determining PNG dimensions... */
static void
png_dimensions (const char *filename,
......@@ -84,15 +86,26 @@ release (cairo_pattern_t *pattern, void *closure, cairo_surface_t *image)
cairo_surface_destroy (image);
}
static void
free_filename(void)
{
free (png_filename);
}
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const char *png_filename = "png.png";
cairo_pattern_t *png, *red;
cairo_content_t content;
int png_width, png_height;
int i, j;
if (png_filename == NULL) {
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
xasprintf (&png_filename, "%s/png.png", ctx->srcdir);
atexit (free_filename);
}
png_dimensions (png_filename, &content, &png_width, &png_height);
png = cairo_pattern_create_raster_source ((void*)png_filename,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment