Mercurial > MadButterfly
diff src/redraw_man.c @ 79:5bcb329a5157
Fix bug of core dump caused by forget to check if parent is NULL, root.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 20 Aug 2008 23:47:18 +0800 |
parents | 23bc382d9683 |
children | 9b4a02bcaeb1 |
line wrap: on
line diff
--- 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;