[cairo] Finished surface

Christophe TROESTLER Christophe.Troestler at umons.ac.be
Thu Aug 8 11:50:55 PDT 2013


Hi,

According to the manual¹, after a surface is finished, "Further
drawing to the surface will [...] trigger a
CAIRO_STATUS_SURFACE_FINISHED error."  However the attached code
shows that cairo_stroke aborts the program instead of setting the
appropriate error.  Is this considered the right behavior?  Is there a
way to avoid the abort and have an error instead (I did not see any
way of testing whether a surface is finished or not — this would alow
testing before running cairo_stroke).

Best,
Chris


¹ http://www.cairographics.org/manual/cairo-cairo-surface-t.html#cairo-surface-finish
-------------- next part --------------
#include <stdio.h>
#include <cairo/cairo.h>
#include <cairo/cairo-svg.h>

void print_status(cairo_t *ctx)
{
  cairo_status_t st;

  st = cairo_status(ctx);
  printf("status = %s\n", cairo_status_to_string(st));
  fflush(stdout);
}


int main(void)
{
  cairo_surface_t * surf;
  cairo_t *ctx;
  
  surf = cairo_svg_surface_create("finish.svg", 100., 100.);
  ctx = cairo_create(surf);
  
  cairo_set_line_width(ctx, 1.);
  cairo_move_to(ctx, 0., 0.);
  cairo_line_to(ctx, 100., 100.);
  cairo_stroke(ctx);
  cairo_surface_finish(surf);

  cairo_line_to(ctx, 100., 100.);
  print_status(ctx);  
  cairo_stroke(ctx);
  print_status(ctx);
  
  return(0);
}


/* Local Variables: */
/* compile-command: "gcc -o finish finish.c -lcairo" */
/* End: */


More information about the cairo mailing list