Changeset 421

Show
Ignore:
Timestamp:
02/05/2008 17:59:23 (7 months ago)
Author:
why
Message:
  • shoes/canvas.c: slight optimization and crash-prevention by removing items according to their type.
Location:
trunk/shoes
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/shoes/canvas.c

    r417 r421  
    11281128 
    11291129void 
    1130 shoes_canvas_remove_item(VALUE self, VALUE item) 
     1130shoes_canvas_remove_item(VALUE self, VALUE item, char c, char t) 
    11311131{ 
    11321132  long i; 
     
    11341134  Data_Get_Struct(self, shoes_canvas, self_t); 
    11351135#ifndef SHOES_GTK 
    1136   i = rb_ary_index_of(self_t->slot.controls, item); 
    1137   if (i >= 0) 
    1138     rb_ary_insert_at(self_t->slot.controls, i, 1, Qnil); 
    1139 #endif 
    1140   i = rb_ary_index_of(self_t->app->timers, item); 
    1141   if (i >= 0) 
    1142     rb_ary_insert_at(self_t->app->timers, i, 1, Qnil); 
     1136  if (c) 
     1137  { 
     1138    i = rb_ary_index_of(self_t->slot.controls, item); 
     1139    if (i >= 0) 
     1140      rb_ary_insert_at(self_t->slot.controls, i, 1, Qnil); 
     1141  } 
     1142#endif 
     1143  if (t) 
     1144  { 
     1145    i = rb_ary_index_of(self_t->app->timers, item); 
     1146    if (i >= 0) 
     1147      rb_ary_insert_at(self_t->app->timers, i, 1, Qnil); 
     1148  } 
    11431149  rb_ary_delete(self_t->contents, item); 
    11441150} 
     
    11961202  Data_Get_Struct(self, shoes_canvas, self_t); 
    11971203  shoes_canvas_empty(self_t); 
    1198   shoes_canvas_remove_item(self_t->parent, self); 
     1204  shoes_canvas_remove_item(self_t->parent, self, 0, 0); 
    11991205  return self; 
    12001206} 
     
    18401846#endif 
    18411847 
    1842   INFO("motion(%d, %d)\n", x, y); 
    1843  
    18441848  if (ATTR(self_t->attr, hidden) != Qtrue) 
    18451849  { 
  • trunk/shoes/canvas.h

    r416 r421  
    292292VALUE shoes_canvas_imagesize(VALUE, VALUE); 
    293293VALUE shoes_canvas_shape(int, VALUE *, VALUE); 
    294 void shoes_canvas_remove_item(VALUE, VALUE); 
     294void shoes_canvas_remove_item(VALUE, VALUE, char, char); 
    295295VALUE shoes_canvas_move_to(VALUE, VALUE, VALUE); 
    296296VALUE shoes_canvas_line_to(VALUE, VALUE, VALUE); 
  • trunk/shoes/ruby.c

    r420 r421  
    657657{ 
    658658  GET_STRUCT(shape, self_t); 
    659   shoes_canvas_remove_item(self_t->parent, self); 
     659  shoes_canvas_remove_item(self_t->parent, self, 0, 0); 
    660660  return self; 
    661661} 
     
    844844{ 
    845845  GET_STRUCT(image, self_t); 
    846   shoes_canvas_remove_item(self_t->parent, self); 
     846  shoes_canvas_remove_item(self_t->parent, self, 0, 0); 
    847847  return self; 
    848848} 
     
    10461046  shoes_canvas *canvas; 
    10471047  GET_STRUCT(video, self_t); 
    1048   shoes_canvas_remove_item(self_t->parent, self); 
     1048  shoes_canvas_remove_item(self_t->parent, self, 1, 0); 
    10491049 
    10501050  Data_Get_Struct(self_t->parent, shoes_canvas, canvas); 
     
    14031403{ 
    14041404  GET_STRUCT(pattern, self_t); 
    1405   shoes_canvas_remove_item(self_t->parent, self); 
     1405  shoes_canvas_remove_item(self_t->parent, self, 0, 0); 
    14061406  return self; 
    14071407} 
     
    18931893{ 
    18941894  GET_STRUCT(textblock, self_t); 
    1895   shoes_canvas_remove_item(self_t->parent, self); 
     1895  shoes_canvas_remove_item(self_t->parent, self, 0, 0); 
    18961896  return self; 
    18971897} 
     
    25982598  shoes_canvas *canvas; 
    25992599  GET_STRUCT(control, self_t); 
    2600   shoes_canvas_remove_item(self_t->parent, self); 
     2600  shoes_canvas_remove_item(self_t->parent, self, 1, 0); 
    26012601 
    26022602  Data_Get_Struct(self_t->parent, shoes_canvas, canvas); 
     
    35413541  GET_STRUCT(anim, self_t); 
    35423542  shoes_anim_stop(self); 
    3543   shoes_canvas_remove_item(self_t->parent, self); 
     3543  shoes_canvas_remove_item(self_t->parent, self, 0, 1); 
    35443544  return self; 
    35453545}