# HG changeset patch # User Thinker K.F. Li # Date 1282708710 -28800 # Node ID 24038e7a365b8bfc4d5f1e75029329b54c70f125 # Parent d8764f10e141359b603308cda114ccc46ae888b5 Reorder instructions to invalidate coords correctly diff -r d8764f10e141 -r 24038e7a365b nodejs/coord.cc --- a/nodejs/coord.cc Wed Aug 25 10:40:30 2010 +0800 +++ b/nodejs/coord.cc Wed Aug 25 11:58:30 2010 +0800 @@ -67,8 +67,8 @@ */ static void xnjsmb_coord_invalidate_subtree(Handle self) { - Handle *child_hdl; - Handle *mem_hdl; + Persistent *child_hdl; + Persistent *mem_hdl; redraw_man_t *rdman; coord_t *coord, *child; shape_t *mem; @@ -81,18 +81,17 @@ /* Invalidate all coords in the subtree */ FOR_COORDS_PREORDER(coord, child) { - child_hdl = (Handle *)mb_prop_get(&child->obj.props, - PROP_JSOBJ); - child = (coord_t *)UNWRAP(*child_hdl); + child_hdl = (Persistent *)mb_prop_get(&child->obj.props, + PROP_JSOBJ); + SET(*child_hdl, "valid", _false); WRAP(*child_hdl, NULL); - SET(*child_hdl, "valid", _false); /* Invalidate members of a coord */ FOR_COORD_SHAPES(child, mem) { - mem_hdl = (Handle *)mb_prop_get(&mem->obj.props, - PROP_JSOBJ); + mem_hdl = (Persistent *)mb_prop_get(&mem->obj.props, + PROP_JSOBJ); + SET(*mem_hdl, "valid", _false); WRAP(*mem_hdl, NULL); - SET(*mem_hdl, "valid", _false); } } } diff -r d8764f10e141 -r 24038e7a365b nodejs/testcase.js --- a/nodejs/testcase.js Wed Aug 25 10:40:30 2010 +0800 +++ b/nodejs/testcase.js Wed Aug 25 11:58:30 2010 +0800 @@ -42,6 +42,13 @@ paint.fill(rect); root.add_shape(rect); +/* test removing a coord */ +var rm_coord = mb_rt.coord_new(root); +var rm_rect = mb_rt.rect_new(150, 150, 50, 50, 10, 10); +paint.fill(rm_rect); +rm_coord.add_shape(rm_rect); +setTimeout(function() { rm_coord.remove(); }, 3000); + /* Moving a path */ sys.puts(mb_rt.path_new); var path = mb_rt.path_new("m 100,50 L 120,50 L 200,150 L 180,150 z");