changeset 1377:8ecee58c85c6

Fix issue of crashing for cloned subtree
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 13 Mar 2011 08:10:57 +0800
parents 4c5bcaba28ea
children 9ce82873d406
files nodejs/coord.cc nodejs/coord.m4 nodejs/mbfly_njs.cc nodejs/mbfly_njs.h
diffstat 4 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/coord.cc	Fri Mar 11 14:07:55 2011 +0800
+++ b/nodejs/coord.cc	Sun Mar 13 08:10:57 2011 +0800
@@ -232,6 +232,15 @@
     xnjsmb_coord_free_subtree(rdman, coord);
 }
 
+static void
+_xnjsmb_coord_clone_from_subtree_mod(Handle<Object> src, Handle<Value> ret) {
+    Handle<Object> js_rt;
+    Handle<Object> ret_obj = ret->ToObject();
+
+    js_rt = GET(src, "mbrt")->ToObject();
+    SET(ret_obj, "mbrt", js_rt);
+}
+
 static coord_t *
 xnjsmb_coord_clone_from_subtree(coord_t *coord, Handle<Object> self,
 				coord_t *src, const char **err) {
--- a/nodejs/coord.m4	Fri Mar 11 14:07:55 2011 +0800
+++ b/nodejs/coord.m4	Sun Mar 13 08:10:57 2011 +0800
@@ -11,7 +11,7 @@
 	 METHOD([clone_from_subtree], [xnjsmb_coord_clone_from_subtree],
 	 	(SELF, OBJ([src], [coord], [coord_t]), ERR), 1,
 		[OBJ([coord], [coord_t])],
-		(([MOD], [xnjsmb_mb_rt_objs_mod]))),
+		(([MOD], [_xnjsmb_coord_clone_from_subtree_mod]))),
 	 METHOD([show], [xnjsmb_coord_show], (SELF), 0, []),
 	 METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, [])],
 	((GET_INDEX, (coord_get_index, NUMBER)),
--- a/nodejs/mbfly_njs.cc	Fri Mar 11 14:07:55 2011 +0800
+++ b/nodejs/mbfly_njs.cc	Sun Mar 13 08:10:57 2011 +0800
@@ -33,8 +33,8 @@
     return coord;
 }
 
-void
-_xnjsmb_mb_rt_objs_mod(Handle<Object> mbrt, Handle<Value> ret) {
+static void
+xnjsmb_mb_rt_objs_mod(Handle<Object> mbrt, Handle<Value> ret) {
     Handle<Object> ret_obj = ret->ToObject();
 
     SET(ret_obj, "mbrt", mbrt);
--- a/nodejs/mbfly_njs.h	Fri Mar 11 14:07:55 2011 +0800
+++ b/nodejs/mbfly_njs.h	Sun Mar 13 08:10:57 2011 +0800
@@ -77,8 +77,4 @@
 v8::Handle<v8::Value> export_xnjsmb_auto_subject_new(subject_t *subject);
 void xnjsmb_observer_init(void);
 
-extern void _xnjsmb_mb_rt_objs_mod(v8::Handle<v8::Object> mbrt,
-				  v8::Handle<v8::Value> ret);
-#define xnjsmb_mb_rt_objs_mod _xnjsmb_mb_rt_objs_mod
-
 #endif /* __MBFLY_NJS_H_ */