[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Confused by Lua garbage collection tear down order when there are references between objects
- From: Coda Highland <chighland@...>
- Date: Wed, 21 May 2014 19:57:09 -0700
On Wed, May 21, 2014 at 7:32 PM, Eric Wing <ewmailing@gmail.com> wrote:
> I think this always works for the SDL case because you always need to
> create the renderer first. But I have another library with a similar
> problem (physics library) where you need to add bodies to the world.
> The world doesn't like bodies being deleted out from under it simular
> to the renderer case. But unfortunately, worlds can be created after
> bodies (because bodies can be put in different worlds in this case).
>
> Thanks,
> Eric
At this point, my personal recommendation would be to use tables
containing a lightuserdata, and maintain a C-side refcount independent
of the Lua refcount. This has the additional advantage of simplifying
the task of mapping bodies returned from e.g. collision queries back
to Lua objects.
/s/ Adam