<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Experts,<div>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:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"># ~/supplibs/src/cairo/bin/cairo-trace ./xopen</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">calling cairo_xlib_surface_create...</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">Assertion failed: (cairo_xlib_surface_create_real != NULL), function cairo_xlib_surface_create, file trace.c, line 4737.</span></font></div><div><br></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div>No window pops up. After a pause, this second error message appears:</div><div><br></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">/Users/jma/supplibs/src/cairo/bin/cairo-trace: line 136: 33085 Abort trap: 6 (core dumped) CAIRO_TRACE_OUTDIR=`pwd` "$@"</span></font></div></div><div><br></div><div>The program does compile and run, except the rectangle drawn is not red, it is white. This is the problem I need to debug. </div><div>Please help! I have run out of ideas. </div><div>--Jennifer Adams</div><div><br></div><div><br></div><div>p.s. Here is my program:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">#include <stdio.h></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">#include <stdlib.h></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">#include <cairo.h></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">#include <cairo-xlib.h></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">static void handle_events(Display *);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">static Window win;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">static Visual *visual;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">static KeyCode quit;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">int main () {</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> Display *display = (Display *)NULL; </span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_surface_t *surface;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_t *cr;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> int snum;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* Connect to X server */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> display = XOpenDisplay(0);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> </span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* Create window, size is 500x500 */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> snum = DefaultScreen(display);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> win = XCreateSimpleWindow(display, RootWindow(display,snum),</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre"> </span> 100, 0, 500, 500, 4,</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre"> </span> BlackPixel(display,snum), WhitePixel(display,snum));</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* Set event type 'Q' for quit */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> quit = XKeysymToKeycode(display, XStringToKeysym("Q"));</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> XSelectInput(display, win, KeyPressMask|StructureNotifyMask|ExposureMask);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> </span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* Display Window */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> XMapWindow(display, win);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* open a cairo surface in the window */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> visual = DefaultVisual(display,snum);</span></font></div><div><span class="Apple-style-span" style="font-family: Courier; font-size: 13px; "><div> printf("calling cairo_xlib_surface_create...\n");</div></span><span class="Apple-style-span" style="font-family: Courier; font-size: 13px; "> surface = cairo_xlib_surface_create (display, win, visual, 500, 500);</span></div><div><span class="Apple-style-span" style="font-family: Courier; font-size: 13px; "> printf("...done\n");</span></div><div><span class="Apple-style-span" style="font-family: Courier; font-size: 13px; "> cr = cairo_create(surface);</span></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* fill red background */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_set_source_rgb(cr,1,0,0);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_rectangle(cr,0,0,500,500);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_fill(cr);</span></font></div><div><span class="Apple-style-span" style="font-family: Courier; font-size: 13px; "> handle_events(display);</span></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> /* clean up the window */</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_destroy(cr);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_surface_finish (surface);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> cairo_surface_destroy (surface);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> return 0;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">}</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">static void handle_events(Display *display) {</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> XEvent xev;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> while (1) {</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> XNextEvent(display, &xev);</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> switch(xev.type) {</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> case KeyPress:</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> {</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre"> </span>XKeyEvent *kev = &xev.xkey;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre"> </span>if (kev->keycode == quit) return;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> }</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> break;</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> }</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"> }</span></font></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;">}</span></font></div></div><div><font class="Apple-style-span" face="Courier"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><br></div><div><br></div><div><div apple-content-edited="true">
<span class="Apple-style-span" style="font-size: 12px; "><div><br></div></span></div></div></body></html>