Mercurial > MadButterfly
comparison 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 |
comparison
equal
deleted
inserted
replaced
78:3645e29e4986 | 79:5bcb329a5157 |
---|---|
656 } | 656 } |
657 | 657 |
658 #ifndef UNITTEST | 658 #ifndef UNITTEST |
659 static void clean_canvas(cairo_t *cr) { | 659 static void clean_canvas(cairo_t *cr) { |
660 /*! \todo clean to background color. */ | 660 /*! \todo clean to background color. */ |
661 cairo_set_source_rgb(cr, 0, 0, 0); | 661 cairo_set_source_rgb(cr, 1, 1, 1); |
662 cairo_paint(cr); | 662 cairo_paint(cr); |
663 } | 663 } |
664 | 664 |
665 static void make_clip(cairo_t *cr, int n_dirty_areas, | 665 static void make_clip(cairo_t *cr, int n_dirty_areas, |
666 area_t **dirty_areas) { | 666 area_t **dirty_areas) { |
937 } | 937 } |
938 | 938 |
939 static subject_t *ob_get_parent_subject(ob_factory_t *factory, | 939 static subject_t *ob_get_parent_subject(ob_factory_t *factory, |
940 subject_t *cur_subject) { | 940 subject_t *cur_subject) { |
941 redraw_man_t *rdman; | 941 redraw_man_t *rdman; |
942 coord_t *coord; | 942 coord_t *coord, *parent_coord; |
943 geo_t *geo; | 943 geo_t *geo; |
944 subject_t *parent; | 944 subject_t *parent; |
945 | 945 |
946 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); | 946 rdman = MEM2OBJ(factory, redraw_man_t, ob_factory); |
947 switch(cur_subject->obj_type) { | 947 switch(cur_subject->obj_type) { |
948 case OBJT_GEO: | 948 case OBJT_GEO: |
949 geo = (geo_t *)cur_subject->obj; | 949 geo = (geo_t *)cur_subject->obj; |
950 coord = geo->shape->coord; | 950 parent_coord = geo->shape->coord; |
951 parent = coord->mouse_event; | 951 parent = parent_coord->mouse_event; |
952 break; | 952 break; |
953 case OBJT_COORD: | 953 case OBJT_COORD: |
954 coord = (coord_t *)cur_subject->obj; | 954 coord = (coord_t *)cur_subject->obj; |
955 coord = coord->parent; | 955 parent_coord = coord->parent; |
956 parent = coord->mouse_event; | 956 if(parent_coord == NULL) { |
957 parent = NULL; | |
958 break; | |
959 } | |
960 parent = parent_coord->mouse_event; | |
957 break; | 961 break; |
958 default: | 962 default: |
959 parent = NULL; | 963 parent = NULL; |
960 break; | 964 break; |
961 } | 965 } |