mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-20 04:40:07 +01:00
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.
This commit is contained in:
parent
4645ecf3f8
commit
1676935768
1 changed files with 14 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue