[cairo] cairo-trace error
Jennifer Adams
jma at cola.iges.org
Fri May 31 09:02:12 PDT 2013
Dear Experts,
I would like to create a trace file in order to do some debugging. I am using cairo 1.12.8 on a mac running OS X 10.7.5. My sample C program (xopen.c, copied below) is supposed to open an X window and fill it with a red rectangle. I am invoking cairo-trace without any options. Here is the error output:
# ~/supplibs/src/cairo/bin/cairo-trace ./xopen
calling cairo_xlib_surface_create...
Assertion failed: (cairo_xlib_surface_create_real != NULL), function cairo_xlib_surface_create, file trace.c, line 4737.
No window pops up. After a pause, this second error message appears:
/Users/jma/supplibs/src/cairo/bin/cairo-trace: line 136: 33085 Abort trap: 6 (core dumped) CAIRO_TRACE_OUTDIR=`pwd` "$@"
The program does compile and run, except the rectangle drawn is not red, it is white. This is the problem I need to debug.
Please help! I have run out of ideas.
--Jennifer Adams
p.s. Here is my program:
#include <stdio.h>
#include <stdlib.h>
#include <cairo.h>
#include <cairo-xlib.h>
static void handle_events(Display *);
static Window win;
static Visual *visual;
static KeyCode quit;
int main () {
Display *display = (Display *)NULL;
cairo_surface_t *surface;
cairo_t *cr;
int snum;
/* Connect to X server */
display = XOpenDisplay(0);
/* Create window, size is 500x500 */
snum = DefaultScreen(display);
win = XCreateSimpleWindow(display, RootWindow(display,snum),
100, 0, 500, 500, 4,
BlackPixel(display,snum), WhitePixel(display,snum));
/* Set event type 'Q' for quit */
quit = XKeysymToKeycode(display, XStringToKeysym("Q"));
XSelectInput(display, win, KeyPressMask|StructureNotifyMask|ExposureMask);
/* Display Window */
XMapWindow(display, win);
/* open a cairo surface in the window */
visual = DefaultVisual(display,snum);
printf("calling cairo_xlib_surface_create...\n");
surface = cairo_xlib_surface_create (display, win, visual, 500, 500);
printf("...done\n");
cr = cairo_create(surface);
/* fill red background */
cairo_set_source_rgb(cr,1,0,0);
cairo_rectangle(cr,0,0,500,500);
cairo_fill(cr);
handle_events(display);
/* clean up the window */
cairo_destroy(cr);
cairo_surface_finish (surface);
cairo_surface_destroy (surface);
return 0;
}
static void handle_events(Display *display) {
XEvent xev;
while (1) {
XNextEvent(display, &xev);
switch(xev.type) {
case KeyPress:
{
XKeyEvent *kev = &xev.xkey;
if (kev->keycode == quit) return;
}
break;
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130531/d4dd440d/attachment.html>
More information about the cairo
mailing list