On Wed, Feb 10, 2010 at 4:50 PM, Gustavo Sverzut Barbieri
<[email protected]> wrote:
> Hi all,
>
> I don't know Lua (yet), but if someone can look at
> edje_lua.c/edje_file.c, the deletion of an Edje object does not delete
> associated resources such as timers, idlers, animators.
>
> I'll dig into this, but any help is appreciated.
>
> See attached files for working example of the problem. Run and it will
> crash as timer will tick but referring object is gone. Code is
> courtesy of Rafael Fonseca, who spotted the problem.
Ok, I spent lots of time trying to figure this out, without any luck
(maybe choosing to solve the problem without really knowing lua C api
was not a wise idea). My findings follows:
--> garbage collector runs, but the code to automatically call
"obj.del" is commented out. Uncommenting this does not work, and I
tried a lot of options to make this work, without luck:
static int
_edje_lua_class_mt_gc(lua_State *L)
{
_edje_lua_checkudata(L, 1, &mClass);
//printf("_edje_lua_class_mt_gc\n");
/* FIXME has to be commented to not raise an error, solve differently
lua_getfield(L, 1, "del");
if (!lua_isnil(L, -1))
{
lua_pushvalue(L, 1);
int err_code;
if (err_code = lua_pcall(L, 1, 0, 0))
_edje_lua_error(L, err_code);
}
lua_pop(L, 1);
*/
return 0;
}
So I opted to go back to my knowledge area and added a free() callback
to all Edje_Lua_*, if set this callback would be called, in
Edje_Lua_Timer, it would call ecore_timer_del().
It did not work, so I realized that the pointer returned by
_edje_lua_checkudata(L, 1, &mClass) is not returning the allocated
userdata created by:
static int
_edje_lua_group_fn_timer(lua_State *L)
{
Edje_Lua_Timer *tar = lua_newuserdata(L, sizeof(Edje_Lua_Timer));
_edje_lua_set_class(L, -1, cTimer);
tar->et = ecore_timer_add(luaL_checknumber(L, 2), _edje_lua_timer_cb, tar);
tar->L = L;
_edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_timer_cb/del
tar->cb = _edje_lua_new_ref(L, 3); // freed in _edje_lua_timer_cb/del
return 1;
}
AFAIU, the "tar" pointer created here is the one to get as first
argument for garbage collector with lua_touserdata(). Probably solving
this issue will make the commented code work, with "del" being called
and releasing resources.
Last, I read some code from lua's own libraries and they make lots of
use of luaL (aux/helpers) that we don't. Any reason for this? Seems
that using things like luaL_newmetatable(), luaL_checkudata() is much
easier than reimplementing it all in Edje.
Any help is appreciated.
BR,
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel