From: John L. <jr...@us...> - 2007-08-02 23:09:02
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16855/wxLua/modules/wxlua/src Modified Files: wxlcallb.cpp wxlstate.cpp Log Message: Fix for wxLuaFunctions in wxlua_tpushusertag, don't try to reuse the userdata since wxLuaFunctions are one shot only. If in an event handler and wx.wxPostEvent(win, wx.wxCommandEvent(..)) was called and ALSO handled by the window the memory from the temp event could be reused by the wxLuaFunction and wxlua_tpushusertag would return the old userdata at the reused address which was wrong. Clear things in wxlcallb.cpp for deleted windows Don't use 0x%p since gcc adds 0x for us, however MSVC6 doesn't Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** wxlstate.cpp 1 Aug 2007 19:15:38 -0000 1.126 --- wxlstate.cpp 2 Aug 2007 23:08:57 -0000 1.127 *************** *** 334,350 **** // When il2 gets gc it will delete il even though il may still be valid and used by the notebook. ! wxlua_pushkey_wxLuaObjects(L); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) ! lua_pushlightuserdata(L, (void*)u); // key on Lua's userdata ! lua_rawget(L, -2); ! ! if (wxlua_iswxuserdata(L, -1)) { ! lua_remove(L, -2); // remove the obj table ! return true; ! } ! // pop the table and the nil. ! lua_pop(L, 2); // Wrap the void* pointer in a newuserdata --- 334,354 ---- // When il2 gets gc it will delete il even though il may still be valid and used by the notebook. ! // we don't track the wxLuaFunctions for speed ! if (tag != g_wxluatag_wxLuaFunction) { ! wxlua_pushkey_wxLuaObjects(L); ! lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) ! lua_pushlightuserdata(L, (void*)u); // key on Lua's userdata ! lua_rawget(L, -2); ! if (wxlua_iswxuserdata(L, -1)) ! { ! lua_remove(L, -2); // remove the obj table ! return true; ! } ! ! // pop the table and the nil. ! lua_pop(L, 2); ! } // Wrap the void* pointer in a newuserdata *************** *** 364,368 **** lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) ! lua_pushlightuserdata(L, (void*)u); // key on Lua's userdata lua_pushvalue(L, -3); // push the lua userdata as the value (note: weak valued table) --- 368,372 ---- lua_rawget(L, LUA_REGISTRYINDEX); // pop key, push result (the obj table) ! lua_pushlightuserdata(L, (void*)u); // key on the object since we can reuse the userdata lua_pushvalue(L, -3); // push the lua userdata as the value (note: weak valued table) *************** *** 376,379 **** --- 380,385 ---- wxlua_terror(L, "wxLua: Unable to set metatable in tpushusertag."); } + else + wxlua_terror(L, "wxLua: Unable to get metatable in tpushusertag."); } else Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** wxlcallb.cpp 26 Jul 2007 18:56:39 -0000 1.35 --- wxlcallb.cpp 2 Aug 2007 23:08:57 -0000 1.36 *************** *** 88,91 **** --- 88,93 ---- // delete the reference to this handler since we're clearing it wxlState.RemoveTrackedCallback(theCallback); + // remove tracking or derived methods for it + wxlState.RemoveTrackedObject(event.GetEventObject(), wxLuaState::CLEAR_TRACKED_OBJECT|wxLuaState::CLEAR_DERIVED_METHODS); // Disconnect all callbacks associated with this window's evthandler *************** *** 106,109 **** --- 108,113 ---- wxlState.GetTrackedCallbackList()->Erase(pc_node); + // remove the ref to the routine since we're clearing the wxLuaState + wxlState.tremove(wxlCallback->m_routine); wxlCallback->ClearwxLuaState(); } |