diff nodejs/coord.cc @ 748:56a5e08cd8af

Make shapes can be removed from the tree
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 25 Aug 2010 18:46:47 +0800
parents 1dbc74a14199
children ed59e659a202
line wrap: on
line diff
--- a/nodejs/coord.cc	Wed Aug 25 18:22:32 2010 +0800
+++ b/nodejs/coord.cc	Wed Aug 25 18:46:47 2010 +0800
@@ -196,6 +196,7 @@
 xnjsmb_coord_add_shape(coord_t *coord, Handle<Object> self,
 			shape_t *shape, const char **err) {
     Handle<Object> js_rt;
+    Persistent<Object> *shape_hdl;
     redraw_man_t *rdman;
     int r;
     
@@ -204,6 +205,11 @@
     r = rdman_add_shape(rdman, shape, coord);
     if(r != 0)
 	*err = "Unknown error";
+
+    /* see \ref jsgc */
+    shape_hdl = (Persistent<Object> *)mb_prop_get(&shape->obj.props,
+						  PROP_JSOBJ);
+    shape_hdl->ClearWeak();
 }
 
 static void