Closed owen200008 closed 7 years ago
cocos2dx lua5.1 all error in lua_ref_impl.hpp:300 lua_rawgeti(state, LUAREGISTRYINDEX, ref.ref());(push funtion)
if the bind function call in coroutine the the coroutine exit. C/C++ code call the lua bind function in main lua state. is it possible create this error?
ok, it is error. how to call the function in main lua state. it contain the state coroutine lua state
now the problem is how to to mainthread in lua5.1
inline lua_State toMainThread(lua_State state) {
if (state) { lua_rawgeti(state, LUA_REGISTRYINDEX, LUA_RIDX_MAINTHREAD); lua_State *mainthread = lua_tothread(state, -1); lua_pop(state, 1); if (mainthread) { return mainthread; } }
return state; }
I'm sorry , I don't know how to get main thread from coroutine in lua5.1. How about the following plan? I implement to function for register main thread and use that in toMainThread. If you can call any function from main thread, you register it.
i think so. register callbck is better, default is same
if use this way, it will be error!