diff --git a/src/ecmascript/mujs.c b/src/ecmascript/mujs.c index 559e47c68..6fe941a28 100644 --- a/src/ecmascript/mujs.c +++ b/src/ecmascript/mujs.c @@ -90,8 +90,8 @@ mujs_init(struct module *xxx) map_forms = attr_create_new_map(); map_rev_forms = attr_create_new_map(); map_inputs = attr_create_new_map(); - map_nodelist = attr_create_new_map(); - map_rev_nodelist = attr_create_new_map(); + //map_nodelist = attr_create_new_map(); + //map_rev_nodelist = attr_create_new_map(); //js_module_init_ok = spidermonkey_runtime_addref(); } @@ -113,8 +113,8 @@ mujs_done(struct module *xxx) attr_delete_map(map_forms); attr_delete_map(map_rev_forms); attr_delete_map(map_inputs); - attr_delete_map(map_nodelist); - attr_delete_map(map_rev_nodelist); + //attr_delete_map(map_nodelist); + //attr_delete_map(map_rev_nodelist); // if (js_module_init_ok) // spidermonkey_runtime_release(); @@ -214,6 +214,8 @@ mujs_put_interpreter(struct ecmascript_interpreter *interpreter) assert(interpreter); js_State *J = (js_State *)interpreter->backend_data; #ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before js_gc: %s:%d\n", __FUNCTION__, __LINE__); + js_gc(J, 0); fprintf(stderr, "Before js_freestate: %s:%d\n", __FUNCTION__, __LINE__); #endif js_freestate(J); diff --git a/src/ecmascript/mujs/document.c b/src/ecmascript/mujs/document.c index 93508439a..488241e2c 100644 --- a/src/ecmascript/mujs/document.c +++ b/src/ecmascript/mujs/document.c @@ -1349,6 +1349,7 @@ mjs_document_getElementsByTagName(js_State *J) return; } mjs_push_nodelist(J, nodes); + dom_nodelist_unref(nodes); } static void diff --git a/src/ecmascript/mujs/nodelist.c b/src/ecmascript/mujs/nodelist.c index 1b5e4adb7..d07f6e9b9 100644 --- a/src/ecmascript/mujs/nodelist.c +++ b/src/ecmascript/mujs/nodelist.c @@ -22,8 +22,8 @@ #include "ecmascript/mujs/nodelist.h" #include "ecmascript/mujs/window.h" -void *map_nodelist; -void *map_rev_nodelist; +//void *map_nodelist; +//void *map_rev_nodelist; static void mjs_push_nodeList_item2(js_State *J, int idx) @@ -112,7 +112,11 @@ mjs_nodeList_toString(js_State *J) static void mjs_nodeList_finalizer(js_State *J, void *node) { - attr_erase_from_map(map_nodelist, node); + //attr_erase_from_map(map_nodelist, node); + + if (node) { + dom_nodelist_unref((dom_nodelist *)node); + } } #if 0 @@ -147,6 +151,7 @@ mjs_push_nodelist(js_State *J, void *node) #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); #endif + dom_nodelist_ref((dom_nodelist *)node); js_newarray(J); { js_newuserdata(J, "nodelist", node, mjs_nodeList_finalizer); @@ -155,5 +160,5 @@ mjs_push_nodelist(js_State *J, void *node) addmethod(J, "toString", mjs_nodeList_toString, 0); mjs_nodeList_set_items(J, node); } - attr_save_in_map(map_nodelist, node, node); + //attr_save_in_map(map_nodelist, node, node); }