I may be getting a little ahead of myself here as I have not written a minimal example to showcase the problem. However, I know that Sqrat::Function and Sqrat::Table crashes my application if not all of them have destructed when sq_close is called. I'm wondering if this is something that Sqrat should handle or if it should be handled by the user. It is really annoying to get a random segmentation fault and have to find out that it is a limitation of Sqrat causing it. However, Sqrat would have to keep track of all objects it has created in some sort of container to remedy this. Any thoughts?
This post is what prompted this question:
http://forum.squirrel-lang.org/mainsite/forums/default.aspx?g=posts&m=7186
Hmmm.. at first thought I think Sqrat should manage the objects it created. that should be the expectation of the majority of users that Sqrat does as much work as it can for the user...I guess. If we leave to the user to handle it, that seems to be inconvenience for the user in many contexts..
Alternatively we can support both with different constructors or arguments to control which mechanism to use, default to Sqrat controlling the cleanup, and make the user clearly aware of which choice he makes and the consequences. Is that good approach?
I don't think that an alternative is necessary. How do we go about injecting code to happen before sq_close is called? Do we need to force users to call Sqrat::VM::Close (or an equivalent function) or is there a better way?
Last edit: Wizzard 2013-10-07
added a test case for this scenario:
// do something with the table tb
//bomb!
Sqrat::VM is not a class that the user needs to use, as in the above test case.
I am not sure if it is a good requirement that the user should call Sqrat::Object::Release() ... or Sqrat needs to track all Sqrat::Object in a VM
Last edit: Andy Tai 2013-10-18
Do we document that all Sqrat::Object must be destroyed before sq_close is called or do we actually fix it?
Edit: There is no way to fix it without requiring the user to call Sqrat::Close or an equivalent function. This is Squirrel's fault.
Leave this issue open until we document the limitation
Last edit: Wizzard 2013-10-19
Please let me say about example.
It is very strange to call sq_close before destrow all Sqrat objects. It looks like programmer error, just add some text about it in documentation and please do not add something like "or Sqrat needs to track all Sqrat::Object in a VM"