-
-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example/sources/dynamic_object.cpp dangerous example? #1640
Comments
Callstack:
The |
It turns out the issue is that new_index is called from a coroutine. Once that coroutine is done it seems that I cannot use sol::object's anymore that originate from it. Since we store the object ... Is that expected? |
I changed my dynamic_set to: void dynamic_set(const std::string &key, sol::stack_object value)
{
// m_lua is the LuaState of the main thread
if (value.lua_state() != m_lua.lua_state()) {
// This pushes the reference onto the other Lua State and returns a stack reference
// to it.
sol::stack_reference newRef = sol::stack_reference(m_lua, value);
dynamic_set(key, newRef);
return;
}
... that seems to solve the issue. |
Turns out there is "main_object" etc. that does what I manually did. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been using the example/sources/dynamic_object.cpp for my own custom container-like type. I'm now running into crashes in my "sol::meta_function::index" function when it tries to access the stored sol::objects after a garbage collector run a while later.
(I call lua functions in response to various user interactions).
With my limited understanding I explain the crashes as:
Do I misunderstand the way lua keeps track of objects? Can/Should the sol::object keep the lua value "alive"?
The text was updated successfully, but these errors were encountered: