From: John L. <jr...@us...> - 2005-11-28 01:29:27
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17359/wxLua/modules/wxlua/src Modified Files: internal.cpp wxlcallb.cpp wxlstate.cpp Log Message: use wxMemorySize in >2.6 in defsutils.i fix removing callbacks (segfault on exit) Index: internal.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/internal.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** internal.cpp 26 Nov 2005 09:42:27 -0000 1.13 --- internal.cpp 28 Nov 2005 01:28:54 -0000 1.14 *************** *** 230,234 **** bool LUACALL tsettagmethod(lua_State *L, int tag, const char *method, lua_CFunction func, void *pClass /* = NULL*/) { ! if (tag != TLUA_NOTAG && tget(L, tag)) { if (pClass != NULL) --- 230,234 ---- bool LUACALL tsettagmethod(lua_State *L, int tag, const char *method, lua_CFunction func, void *pClass /* = NULL*/) { ! if ((tag != TLUA_NOTAG) && tget(L, tag)) { if (pClass != NULL) *************** *** 833,838 **** lua_newtable(L); ! size_t idx; ! for (idx = 0; idx < files.Count(); ++idx) { const wxString &item = files.Item(idx); --- 833,838 ---- lua_newtable(L); ! size_t idx, count = files.Count(); ! for (idx = 0; idx < count; ++idx) { const wxString &item = files.Item(idx); *************** *** 847,852 **** lua_newtable(L); ! size_t idx; ! for (idx = 0; idx < table.Count(); ++idx) { int item = table.Item(idx); --- 847,852 ---- lua_newtable(L); ! size_t idx, count = table.Count(); ! for (idx = 0; idx < count; ++idx) { int item = table.Item(idx); *************** *** 1122,1128 **** const char *cpIndex = "{unknown}"; ! if ((pClass != NULL) && lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && (ttag(L, 1) == *pClass->class_tag)) { ! void *pObject = ttouserdata(L, 1); cpIndex = lua_tostring(L, 2); --- 1122,1130 ---- const char *cpIndex = "{unknown}"; ! if ((pClass != NULL) && lua_isuserdata(L, 1) && ! (lua_islightuserdata(L, 1) == 0) && ! (wxlState.ttag(1) == *pClass->class_tag)) { ! void *pObject = wxlState.ttouserdata(1); cpIndex = lua_tostring(L, 2); *************** *** 1184,1191 **** const char *cpIndex = lua_tostring(L, 2); ! if ((pClass != NULL) && ! lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && ! (ttag(L, 1) == *pClass->class_tag)) { WXLUAMETHOD *pMethod = wxlState.getLuaProperty(pClass, cpIndex, true); --- 1186,1192 ---- const char *cpIndex = lua_tostring(L, 2); ! if ((pClass != NULL) && lua_isuserdata(L, 1) && (lua_islightuserdata(L, 1) == 0) && ! (wxlState.ttag(1) == *pClass->class_tag)) { WXLUAMETHOD *pMethod = wxlState.getLuaProperty(pClass, cpIndex, true); *************** *** 1197,1201 **** else { ! void *pObject = ttouserdata(L, 1); bool fCreated = false; --- 1198,1202 ---- else { ! void *pObject = wxlState.ttouserdata(1); bool fCreated = false; *************** *** 1311,1315 **** // Create and connect the callback pCallback = new wxLuaCallback(wxlState, 4, id, (int) eventType, evtHandler); - wxlState.GetLuaStateRefData()->m_pAppHandlerList->Append(pCallback); // FIXME see wxCallb constructor break; --- 1312,1315 ---- *************** *** 1348,1352 **** // Create and connect the callback pCallback = new wxLuaCallback(wxlState, 3, id, (int) eventType, evtHandler); - wxlState.GetLuaStateRefData()->m_pAppHandlerList->Append(pCallback); // FIXME see wxCallb constructor } --- 1348,1351 ---- Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** wxlstate.cpp 26 Nov 2005 09:42:27 -0000 1.6 --- wxlstate.cpp 28 Nov 2005 01:28:55 -0000 1.7 *************** *** 302,310 **** { wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); ! ! if (pCallback) ! { ! pCallback->ClearState(); ! } node = node->GetNext(); --- 302,307 ---- { wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); ! pCallback->ClearLuaState(); node = node->GetNext(); *************** *** 314,322 **** { wxLuaDestroyCallback *pCallback = (wxLuaDestroyCallback *) node->GetData(); ! ! if (pCallback) ! { ! pCallback->ClearState(); ! } node = node->GetNext(); --- 311,316 ---- { wxLuaDestroyCallback *pCallback = (wxLuaDestroyCallback *) node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); ! pCallback->ClearLuaState(); node = node->GetNext(); *************** *** 721,726 **** { M_WXLSTATEDATA->m_pWindowList->Append(pWindow); ! wxLuaCallback* pCallback = new wxLuaCallback(*this, 3, pWindow->GetId(), wxEVT_DESTROY, pWindow->GetEventHandler()); ! GetLuaStateRefData()->m_pAppHandlerList->Append(pCallback); // FIXME see wxCallb constructor } } --- 715,719 ---- { M_WXLSTATEDATA->m_pWindowList->Append(pWindow); ! new wxLuaCallback(*this, 3, pWindow->GetId(), wxEVT_DESTROY, pWindow->GetEventHandler()); } } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wxlcallb.cpp 26 Nov 2005 09:42:27 -0000 1.3 --- wxlcallb.cpp 28 Nov 2005 01:28:55 -0000 1.4 *************** *** 54,61 **** // FIXME - Need to track events attached to an application object ! // labenski - track all of them? useful to run ClearState when window is destroyed //if (pEvtHandler->IsKindOf(CLASSINFO(wxApp))) { ! //m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->Append(this); } } --- 54,61 ---- // FIXME - Need to track events attached to an application object ! // labenski - track all of them? useful to run ClearLuaState when window is destroyed //if (pEvtHandler->IsKindOf(CLASSINFO(wxApp))) { ! m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->Append(this); } } *************** *** 72,90 **** } - void wxLuaCallback::ClearState() - { - if (m_wxlState.Ok()) - { - m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->DeleteObject(this); - m_wxlState.UnRef(); - } - } - // This function is called with "this" being of the type which the event is arriving // at. The user data is used to route it to the correct place. void wxLuaCallback::EventHandler(wxEvent& event) { wxLuaCallback *theCallback = (wxLuaCallback *) event.m_callbackUserData; if (!theCallback || !theCallback->GetwxLuaState().Ok()) return; --- 72,83 ---- } // This function is called with "this" being of the type which the event is arriving // at. The user data is used to route it to the correct place. void wxLuaCallback::EventHandler(wxEvent& event) { + // This is the wxLuaCallback to use, NOT "this" wxLuaCallback *theCallback = (wxLuaCallback *) event.m_callbackUserData; + wxCHECK_RET(theCallback != NULL, wxT("Invalid wxLuaCallback in user data")); if (!theCallback || !theCallback->GetwxLuaState().Ok()) return; *************** *** 98,105 **** wxlState.GetLuaStateRefData()->m_pWindowList->DeleteObject((wxWindow*)event.GetEventObject()); // delete the reference to this handler since we're clearing it ! m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->DeleteObject(this); // Disconnect all callbacks associated with this window's evthandler ! theCallback->ClearState(); wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); --- 91,98 ---- wxlState.GetLuaStateRefData()->m_pWindowList->DeleteObject((wxWindow*)event.GetEventObject()); // delete the reference to this handler since we're clearing it ! wxlState.GetLuaStateRefData()->m_pAppHandlerList->DeleteObject(this); // Disconnect all callbacks associated with this window's evthandler ! theCallback->ClearLuaState(); wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); *************** *** 112,121 **** if ((pCallback != NULL) && (pCallback->GetEvtHandler() == evtHandler)) { - // go to new node before we delete it - node = wxlState.GetLuaStateRefData()->m_pAppHandlerList->GetFirst(); // delete the reference to all other handlers that are cleared ! m_wxlState.GetLuaStateRefData()->m_pAppHandlerList->DeleteObject(pCallback); ! pCallback->ClearState(); } else --- 105,114 ---- if ((pCallback != NULL) && (pCallback->GetEvtHandler() == evtHandler)) { // delete the reference to all other handlers that are cleared ! wxNode* pc_node = node; // remember current node ! node = node->GetNext(); ! wxlState.GetLuaStateRefData()->m_pAppHandlerList->Erase(pc_node); ! pCallback->ClearLuaState(); } else *************** *** 123,127 **** } } ! else //if (theCallback->m_luaState) theCallback->CallFunction(&event); --- 116,120 ---- } } ! else theCallback->CallFunction(&event); *************** *** 186,190 **** // and set the metatable of the proxy ! if (iTag != TLUA_NOTAG && tget(L, iTag)) { if (lua_setmetatable(L, -2) == 0) --- 179,183 ---- // and set the metatable of the proxy ! if ((iTag != TLUA_NOTAG) && m_wxlState.tget(iTag)) { if (lua_setmetatable(L, -2) == 0) *************** *** 195,199 **** // get a reference to the destroy handler table ! if (tget(L, m_wxlState.GetLuaStateRefData()->m_wxDeleteTable)) { // create a reference to object --- 188,192 ---- // get a reference to the destroy handler table ! if (m_wxlState.tget(m_wxlState.GetLuaStateRefData()->m_wxDeleteTable)) { // create a reference to object |