comparison nodejs/coord.cc @ 766:be0e02948c1d

Improve resource management for coords, shapes and paints. - Make paint to use weak reference to release resource before collected. - Call Persistent<Object>::Dispose() before deleting the handle variable. Dispose() will real release Persistent handle. Handle variable is just a pointer to the handle.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 29 Aug 2010 13:34:40 +0800
parents ed59e659a202
children 13669b28826d
comparison
equal deleted inserted replaced
765:a49358b040b5 766:be0e02948c1d
79 FOR_COORDS_PREORDER(coord, child) { 79 FOR_COORDS_PREORDER(coord, child) {
80 child_hdl = (Persistent<Object> *)mb_prop_get(&child->obj.props, 80 child_hdl = (Persistent<Object> *)mb_prop_get(&child->obj.props,
81 PROP_JSOBJ); 81 PROP_JSOBJ);
82 SET(*child_hdl, "valid", _false); 82 SET(*child_hdl, "valid", _false);
83 WRAP(*child_hdl, NULL); 83 WRAP(*child_hdl, NULL);
84 child_hdl->Dispose();
84 delete child_hdl; 85 delete child_hdl;
85 86
86 /* Invalidate members of a coord */ 87 /* Invalidate members of a coord */
87 FOR_COORD_SHAPES(child, mem) { 88 FOR_COORD_SHAPES(child, mem) {
88 mem_hdl = (Persistent<Object> *)mb_prop_get(&mem->obj.props, 89 mem_hdl = (Persistent<Object> *)mb_prop_get(&mem->obj.props,
89 PROP_JSOBJ); 90 PROP_JSOBJ);
90 SET(*mem_hdl, "valid", _false); 91 SET(*mem_hdl, "valid", _false);
91 WRAP(*mem_hdl, NULL); 92 WRAP(*mem_hdl, NULL);
93 mem_hdl->Dispose();
92 delete mem_hdl; 94 delete mem_hdl;
93 } 95 }
94 } 96 }
95 } 97 }
96 98