Changeset 446

Show
Ignore:
Timestamp:
03/04/2008 01:46:17 (6 months ago)
Author:
why
Message:
  • shoes/canvas.c: append, prepend, clear. these altering methods had an issue with adding elements in url-style apps. the toplevel slot needs to be added to the nesting before drawing. (spotted by the_hack in ticket #63.)
Location:
trunk/shoes
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/shoes/app.c

    r445 r446  
    2323  rb_gc_mark_maybe(app->location); 
    2424  rb_gc_mark_maybe(app->canvas); 
     25  rb_gc_mark_maybe(app->nestslot); 
    2526  rb_gc_mark_maybe(app->nesting); 
    2627  rb_gc_mark_maybe(app->timers); 
     
    4142  app->location = Qnil; 
    4243  app->canvas = shoes_canvas_new(cShoes, app); 
     44  app->nestslot = Qnil; 
    4345  app->nesting = rb_ary_new(); 
    4446  app->timers = rb_ary_new(); 
     
    7476  shoes_ele_remove_all(app->timers); 
    7577  shoes_canvas_clear(app->canvas); 
     78  app->nestslot = Qnil; 
    7679} 
    7780 
     
    18051808  if (rb_obj_is_kind_of(exec.block, rb_cUnboundMethod)) { 
    18061809    VALUE klass = rb_unbound_get_class(exec.block); 
    1807     exec.canvas = shoes_slot_new(klass, Qnil, app->canvas); 
     1810    exec.canvas = app->nestslot = shoes_slot_new(klass, Qnil, app->canvas); 
    18081811    exec.block = rb_funcall(exec.block, s_bind, 1, exec.canvas); 
    18091812    exec.ieval = 0; 
    18101813    rb_ary_push(canvas->contents, exec.canvas); 
    18111814  } else { 
    1812     exec.canvas = app->canvas; 
     1815    exec.canvas = app->nestslot = app->canvas; 
    18131816    exec.ieval = 1; 
    18141817  } 
  • trunk/shoes/app.h

    r439 r446  
    3434  VALUE self; 
    3535  VALUE canvas; 
     36  VALUE nestslot; 
    3637  VALUE nesting; 
    3738  VALUE timers; 
  • trunk/shoes/canvas.c

    r443 r446  
    14931493 
    14941494#define DRAW(c, app, blk) \ 
    1495   rb_ary_push(app->nesting, c); \ 
    1496   rb_funcall(blk, s_call, 0); \ 
    1497   rb_ary_pop(app->nesting) 
     1495  { \ 
     1496    unsigned char alter = 0; \ 
     1497    if (RARRAY_LEN(app->nesting) == 0) \ 
     1498    { \ 
     1499      alter = 1; \ 
     1500      rb_ary_push(app->nesting, app->nestslot); \ 
     1501    } \ 
     1502    rb_ary_push(app->nesting, c); \ 
     1503    rb_funcall(blk, s_call, 0); \ 
     1504    rb_ary_pop(app->nesting); \ 
     1505    if (alter) \ 
     1506      rb_ary_pop(app->nesting); \ 
     1507  } 
     1508 
    14981509 
    14991510static void