# HG changeset patch # User Thinker K.F. Li # Date 1219247238 -28800 # Node ID 5bcb329a5157c7c74a41e53ffdd4e7f711980cbb # Parent 3645e29e4986a2f38b179faa4bcdb5d5f9ca6db0 Fix bug of core dump caused by forget to check if parent is NULL, root. diff -r 3645e29e4986 -r 5bcb329a5157 examples/svg2code_ex/main.c --- a/examples/svg2code_ex/main.c Wed Aug 20 23:33:04 2008 +0800 +++ b/examples/svg2code_ex/main.c Wed Aug 20 23:47:18 2008 +0800 @@ -8,7 +8,7 @@ svg2code_ex_t *svg2code; int r; - r = X_MB_init(":0.0", 200, 200, &rt); + r = X_MB_init(":0.0", 800, 600, &rt); svg2code = svg2code_ex_new(rt.rdman); X_MB_handle_connection(rt.display, rt.rdman, rt.tman); diff -r 3645e29e4986 -r 5bcb329a5157 src/redraw_man.c --- a/src/redraw_man.c Wed Aug 20 23:33:04 2008 +0800 +++ b/src/redraw_man.c Wed Aug 20 23:47:18 2008 +0800 @@ -658,7 +658,7 @@ #ifndef UNITTEST static void clean_canvas(cairo_t *cr) { /*! \todo clean to background color. */ - cairo_set_source_rgb(cr, 0, 0, 0); + cairo_set_source_rgb(cr, 1, 1, 1); cairo_paint(cr); } @@ -939,7 +939,7 @@ static subject_t *ob_get_parent_subject(ob_factory_t *factory, subject_t *cur_subject) { redraw_man_t *rdman; - coord_t *coord; + coord_t *coord, *parent_coord; geo_t *geo; subject_t *parent; @@ -947,13 +947,17 @@ switch(cur_subject->obj_type) { case OBJT_GEO: geo = (geo_t *)cur_subject->obj; - coord = geo->shape->coord; - parent = coord->mouse_event; + parent_coord = geo->shape->coord; + parent = parent_coord->mouse_event; break; case OBJT_COORD: coord = (coord_t *)cur_subject->obj; - coord = coord->parent; - parent = coord->mouse_event; + parent_coord = coord->parent; + if(parent_coord == NULL) { + parent = NULL; + break; + } + parent = parent_coord->mouse_event; break; default: parent = NULL;