Sorry for my bad English.
I am learning gtk+ 3 as a "helloworld" by following this article https://developer.gnome.org/gtk3/stable/gtk-getting-started.html
My environment:
* Mac OS X 10.8.3
* XQuartz 2.7.4
* GTk+ 3.4.4
* i686-apple-darwin11-llvm-gcc-4.2
Everything worked fine before I tried to invoke this function as a signal handler for drawing:
static gboolean configure_event_cb(GtkWidget* widget,GdkEventConfigure* event,gpointer data) { if(surface) cairo_surface_destroy(surface); surface = gdk_window_create_similar_surface(gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget)); //非对象类型.看做普通的struct. cairo看做类似Graphics的静态类. cairo_t* cr = cairo_create(surface); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_paint(cr); cairo_destroy(cr); return TRUE; }
The program always crashed on the line "cairo_paint(cr)" or "cairo_fill" in other functions. Here is the callstack:
libcairo.2.dylib`_cairo_default_context_in_clip: 0x100a71ff5: pushq %rbp 0x100a71ff6: movq %rsp, %rbp 0x100a71ff9: pushq %rbx 0x100a71ffa: pushq %rax 0x100a71ffb: movq %rsi, %rbx 0x100a71ffe: movq 40(%rdi), %rdi 0x100a72002: callq 0x100a761c1 ; _cairo_gstate_in_clip 0x100a72007: movl %eax, (%rbx) 0x100a72009: xorl %eax, %eax 0x100a7200b: addq $8, %rsp 0x100a7200f: popq %rbx 0x100a72010: popq %rbp 0x100a72011: ret
Could somebody help me?