@@ -295,15 +295,16 @@ void LuaAdaptersScene::CalculatePathAsync2(Scene* luaSelfObject, const luabind::
295
295
// So, luabind::object is a weak reference, holding just a stack and a position in the stack
296
296
// This means it's unsafe to store on the C++ side if we do basically anything with the lua state before using it
297
297
// As such, we need to store this function somewhere safely within our Lua state for us to access later when we need it
298
- // Note that also, the callbackParam's interpreter is actually different from our Lua state.
299
298
// It looks like Luabind constructs temporary interpreters and really doesn't like if you destroy these luabind objects
300
299
// In any case, it's extremely unsafe to use! For example capturing the callback by value into the lambdas causes random crashes
301
300
// Even if we did literally nothing with it except capture it into a no-op lambda
302
- LuaStateWrapper* luaState = g_LuaMan.GetThreadCurrentLuaState ();
301
+ // TODO: validate this is still actually the case. Changes to lua may have fixed this
302
+ lua_State* luaState = callbackParam.interpreter ();
303
303
static int currentCallbackId = 0 ;
304
304
int thisCallbackId = currentCallbackId++;
305
305
if (luabind::type (callbackParam) == LUA_TFUNCTION && callbackParam.is_valid ()) {
306
- luabind::call_function<void >(luaState->GetLuaState (), " _AddAsyncPathCallback" , thisCallbackId, callbackParam);
306
+ g_ConsoleMan.PrintString (std::to_string (reinterpret_cast <unsigned long long >(luaState)));
307
+ luabind::call_function<void >(luaState, " _AddAsyncPathCallback" , thisCallbackId, callbackParam);
307
308
}
308
309
309
310
auto callLuaCallback = [luaState, thisCallbackId, movePathToGround](std::shared_ptr<volatile PathRequest> pathRequestVol) {
@@ -316,7 +317,7 @@ void LuaAdaptersScene::CalculatePathAsync2(Scene* luaSelfObject, const luabind::
316
317
}
317
318
}
318
319
319
- luabind::call_function<void >(luaState-> GetLuaState () , " _TriggerAsyncPathCallback" , thisCallbackId, pathRequest);
320
+ luabind::call_function<void >(luaState, " _TriggerAsyncPathCallback" , thisCallbackId, pathRequest);
320
321
});
321
322
};
322
323
0 commit comments