# HG changeset patch # User Thinker K.F. Li # Date 1258970662 -28800 # Node ID 5d0b2761f89ca739b70fcc7d57bb6278eab76516 # Parent 23c7667b3ec0937e6347fea0108849b5d0974377 Reset stroke and fill for shapes when a paint is freed. - reset stroke or/and fill of shapes with a freeing paint. - remove a shape from member lists of paints of stroke and fill when the shape being freed. diff -r 23c7667b3ec0 -r 5d0b2761f89c include/mb_redraw_man.h --- a/include/mb_redraw_man.h Sun Nov 22 20:41:27 2009 +0800 +++ b/include/mb_redraw_man.h Mon Nov 23 18:04:22 2009 +0800 @@ -157,25 +157,31 @@ #define _rdman_paint_remove_child(rdman, paint, shape) \ do { \ if((shape)->fill == (shape)->stroke && \ - (shape)->stroke == paint) \ + (shape)->stroke == (paint)) \ break; \ _rdman_paint_real_remove_child(rdman, paint, shape); \ } while(0) -#define rdman_paint_fill(rdman, paint, shape) \ - do { \ - if((shape)->fill == paint) \ - break; \ - _rdman_paint_remove_child(rdman, paint, shape); \ - _rdman_paint_child(rdman, paint, shape); \ - (shape)->fill = paint; \ +#define rdman_paint_fill(rdman, paint, shape) \ + do { \ + if((shape)->fill == paint) \ + break; \ + if((shape)->fill) \ + _rdman_paint_remove_child(rdman, (shape)->fill, \ + shape); \ + if(paint) \ + _rdman_paint_child(rdman, paint, shape); \ + (shape)->fill = paint; \ } while(0) -#define rdman_paint_stroke(rdman, paint, shape) \ - do { \ - if((shape)->stroke == paint) \ - break; \ - _rdman_paint_remove_child(rdman, paint, shape); \ - _rdman_paint_child(rdman, paint, shape); \ - (shape)->stroke = paint; \ +#define rdman_paint_stroke(rdman, paint, shape) \ + do { \ + if((shape)->stroke == paint) \ + break; \ + if((shape)->stroke) \ + _rdman_paint_remove_child(rdman, (shape)->stroke, \ + shape); \ + if(paint) \ + _rdman_paint_child(rdman, paint, shape); \ + (shape)->stroke = paint; \ } while(0) extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint); diff -r 23c7667b3ec0 -r 5d0b2761f89c src/redraw_man.c --- a/src/redraw_man.c Sun Nov 22 20:41:27 2009 +0800 +++ b/src/redraw_man.c Mon Nov 23 18:04:22 2009 +0800 @@ -746,6 +746,10 @@ rdman_shape_free(rdman, saved_shape); coord_canvas_info_free(rdman, rdman->root_coord->canvas_info); + + /* XXX: paints are not freed, here. All resources of paints would + * be reclaimed by freeing elmpools. + */ elmpool_free(rdman->coord_pool); elmpool_free(rdman->geo_pool); @@ -841,6 +845,11 @@ return OK; } + if(shape->stroke != NULL) + rdman_paint_stroke(rdman, (paint_t *)NULL, shape); + if(shape->fill != NULL) + rdman_paint_fill(rdman, (paint_t *)NULL, shape); + if(geo != NULL) { subject_free(geo->mouse_event); geo_detach_coord(geo, shape->coord); @@ -854,6 +863,7 @@ if(rdman->last_mouse_over == (mb_obj_t *)shape) rdman->last_mouse_over = NULL; + return OK; } @@ -871,6 +881,7 @@ int rdman_paint_free(redraw_man_t *rdman, paint_t *paint) { shnode_t *shnode, *saved_shnode; + shape_t *shape; if(rdman_is_dirty(rdman)) { if(!(paint->flags & PNTF_FREE)) @@ -885,12 +896,26 @@ FORPAINTMEMBERS(paint, shnode) { if(saved_shnode) { RM_PAINTMEMBER(paint, saved_shnode); + + shape = saved_shnode->shape; + if(shape->stroke == paint) + rdman_paint_stroke(rdman, (paint_t *)NULL, shape); + if(shape->fill == paint) + rdman_paint_fill(rdman, (paint_t *)NULL, shape); + shnode_free(rdman, saved_shnode); } saved_shnode = shnode; } if(saved_shnode) { RM_PAINTMEMBER(paint, saved_shnode); + + shape = saved_shnode->shape; + if(shape->stroke == paint) + rdman_paint_stroke(rdman, (paint_t *)NULL, shape); + if(shape->fill == paint) + rdman_paint_fill(rdman, (paint_t *)NULL, shape); + shnode_free(rdman, saved_shnode); }