[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: interacting with gc
- From: tomas <tomas@...>
- Date: Tue, 07 Mar 2017 14:18:02 -0300
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 the
C API. so, lua has no way to know that the image cannot be freed
linked 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.