|
Hi Pierre
I think you should create a reference to the image userdata and store it in the button userdata. When the button is freed Lua will call the button _gc and then you'll have to release the reference to the image.For example, while binding a GUI library, a button can have an image attached. The image and the button are userdata type, both created in lua (via the C API), but the image is linked to the button also via theC API. so, lua has no way to know that the image cannot be freed becauselinked to another object outside of its control.
How can I tell lua the resource is being used and then no more used (block from gc or ready for gc)?
Check luaL_ref and luaL_unref. Regards, Tomás