From: John L. <jr...@us...> - 2005-12-15 21:45:29
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23190/wxLua/modules/wxlua/src Modified Files: wxlintrp.cpp Log Message: fix tracking lua_States for coroutines Index: wxlintrp.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlintrp.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** wxlintrp.cpp 12 Dec 2005 05:16:32 -0000 1.7 --- wxlintrp.cpp 15 Dec 2005 21:45:21 -0000 1.8 *************** *** 56,64 **** --- 56,84 ---- { // L is the original lua_State, L1 new child thread + wxLuaState wxlState(L); + wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); + + // put into the hashmap + wxLuaStateRefData::s_wxHashMapLuaStateRefData[L1] = wxlState.GetLuaStateRefData(); + + // Stick us into the lua_State - push key, value + lua_pushstring( L1, "__wxLuaStateRefData" ); + lua_pushlightuserdata( L1, (void*)wxlState.GetRefData() ); + // set the value + lua_settable( L1, LUA_REGISTRYINDEX ); + wxLuaInterpreter *L_interp = wxFindLuaInterpreter(L); //printf("Adding new lua_State from a thread L=%ld L1=%ld\n", (long)L, (long)L1); fflush(stdout); if (L_interp != NULL) + { s_wxHashMapLuaInterpreter[L1] = L_interp; + + // Stick us into the lua interpreter - push key, value + lua_pushstring( L1, "__wxLuaInterpreter" ); + lua_pushlightuserdata( L1, L_interp); + // set the value + lua_settable( L1, LUA_REGISTRYINDEX ); + } } *************** *** 69,72 **** --- 89,93 ---- // L is the original lua_State, L1 child thread, don't remove L //printf("Freeing lua_State from a thread L=%ld L1=%ld\n", (long)L, (long)L1); fflush(stdout); + wxLuaStateRefData::s_wxHashMapLuaStateRefData.erase(L1); s_wxHashMapLuaInterpreter.erase(L1); } |