lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>
> What information do I need to save for each member to be able to
> retrieve and modify the object later. My first try (And basicly all my
> tries in different shapes) is releated to save the lua_Object for the
> table and the index .. But this seems to go wrong.. Is the lua_Object a
> safe value to save outside blocks ? Is there an easier way
>

No, lua_Objects are volatile and should never be cached.  Instead, you
should cache _references_ to lua objects.

To convert a lua_Object to a reference:

   lua_pushobject( some_object );
   int cached_ref = lua_ref( 1 );


To convert a reference to a lua_Object:

   lua_Object some_object = lua_getref( cached_ref );


To stop caching the reference:

   lua_unref( cached_ref );

So, your tree control should store references, and then convert the
references to objects as required.

ashley