From: John L. <jr...@us...> - 2006-12-14 01:01:33
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1560/wxLua/modules/wxlua/src Modified Files: wxlbind.cpp wxlcallb.cpp wxlstate.cpp Log Message: speed up genwxbind.lua add wxLuaBinding::GetBindingName as a unique name to know if it's added Rename *AddToTrackedMemory -> AddTrackedObject since it only tracks wxObjects Rename wxLuaState::AddTrackedEventHandler to AddTrackedCallback and only accept wxLuaCallbacks Rename wxLuaState::AddTrackedDestroyEventHandler to AddTrackedWinDestroyCallback and only accept wxLuaWinDestroyCallbacks Make type evaluation for the bindings more strict Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** wxlstate.cpp 12 Dec 2006 07:09:41 -0000 1.84 --- wxlstate.cpp 14 Dec 2006 01:01:26 -0000 1.85 *************** *** 249,253 **** wxLongToLongHashMap::iterator it; ! wxLongToLongHashMap* hashMap = &wxlState.GetLuaStateRefData()->m_wxlStateData->m_pTrackedList; for (it = hashMap->begin(); it != hashMap->end(); ++it) { --- 249,253 ---- wxLongToLongHashMap::iterator it; ! wxLongToLongHashMap* hashMap = &wxlState.GetLuaStateRefData()->m_wxlStateData->m_trackedObjects; for (it = hashMap->begin(); it != hashMap->end(); ++it) { *************** *** 447,453 **** switch (ltype) { ! case LUA_TNIL: case LUA_TSTRING: ! case LUA_TNUMBER: // can convert easily return true; default: --- 447,453 ---- switch (ltype) { ! //case LUA_TNIL: too easy to have a variable typo, use (str or "") case LUA_TSTRING: ! case LUA_TNUMBER: // can convert easily, always works return true; default: *************** *** 463,468 **** switch (ltype) { ! case LUA_TNIL: ! case LUA_TNUMBER: case LUA_TBOOLEAN: return true; --- 463,468 ---- switch (ltype) { ! case LUA_TNIL: // evaluates to false ! case LUA_TNUMBER: // as in C 0 == false case LUA_TBOOLEAN: return true; *************** *** 479,483 **** switch (ltype) { ! case LUA_TNUMBER: // make sure it's only a number for an enum return true; default: --- 479,484 ---- switch (ltype) { ! case LUA_TNIL: // evaluates to 0 so wx.ENUM_typo = 0 ! case LUA_TNUMBER: // make sure it's only a number for an enum return true; default: *************** *** 493,500 **** switch (ltype) { ! case LUA_TNIL: ! //case LUA_TSTRING: // will be 0 unless really a number "2" case LUA_TNUMBER: ! case LUA_TBOOLEAN: return true; default: --- 494,501 ---- switch (ltype) { ! //case LUA_TNIL: evaluates to 0, too easy to have a typo ! //case LUA_TSTRING: will be 0 unless really a number "2" case LUA_TNUMBER: ! case LUA_TBOOLEAN: // can't do (bool_val or 1) return true; default: *************** *** 867,873 **** { // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it ! m_eventHandlerList.DeleteContents(false); ! // don't delete wxLuaDestroyCallbacks, let wxEventHandler do it ! m_destroyHandlerList.DeleteContents(false); // don't delete wxWindow derived classes, let wxWidgets do it m_windowList.DeleteContents(false); --- 868,874 ---- { // don't "own" pointers to wxLuaCallbacks, let wxEventHandler do it ! m_callbackList.DeleteContents(false); ! // don't delete wxLuaWinDestroyCallbacks, let wxEventHandler do it ! m_winDestroyCallbackList.DeleteContents(false); // don't delete wxWindow derived classes, let wxWidgets do it m_windowList.DeleteContents(false); *************** *** 897,906 **** m_pDerivedList.clear(); ! for (it = m_pTrackedList.begin(); it != m_pTrackedList.end(); ++it) { wxObject* obj = (wxObject*)it->second; delete obj; } ! m_pTrackedList.clear(); wxLuaBindingList::Node *node = m_bindingList.GetFirst(); --- 898,907 ---- m_pDerivedList.clear(); ! for (it = m_trackedObjects.begin(); it != m_trackedObjects.end(); ++it) { wxObject* obj = (wxObject*)it->second; delete obj; } ! m_trackedObjects.clear(); wxLuaBindingList::Node *node = m_bindingList.GetFirst(); *************** *** 1006,1011 **** } ! m_wxlStateData->m_eventHandlerList.Clear(); ! m_wxlStateData->m_destroyHandlerList.Clear(); m_wxlStateData->m_windowList.Clear(); } --- 1007,1012 ---- } ! m_wxlStateData->m_callbackList.Clear(); ! m_wxlStateData->m_winDestroyCallbackList.Clear(); m_wxlStateData->m_windowList.Clear(); } *************** *** 1014,1021 **** { // remove any and all callbacks that use this event handler since its gone ! wxNode* node = m_wxlStateData->m_eventHandlerList.GetFirst(); while (node) { ! wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); if (pCallback->GetwxLuaState().GetRefData() != this) // don't unref us --- 1015,1022 ---- { // remove any and all callbacks that use this event handler since its gone ! wxNode* node = m_wxlStateData->m_callbackList.GetFirst(); while (node) { ! wxLuaCallback *pCallback = (wxLuaCallback *)node->GetData(); wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); if (pCallback->GetwxLuaState().GetRefData() != this) // don't unref us *************** *** 1025,1033 **** } ! node = m_wxlStateData->m_destroyHandlerList.GetFirst(); while (node) { ! wxLuaDestroyCallback *pCallback = (wxLuaDestroyCallback *) node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); if (pCallback->GetwxLuaState().GetRefData() != this) // don't unref us pCallback->ClearwxLuaState(); --- 1026,1034 ---- } ! node = m_wxlStateData->m_winDestroyCallbackList.GetFirst(); while (node) { ! wxLuaWinDestroyCallback *pCallback = (wxLuaWinDestroyCallback *) node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaWinDestroyCallback")); if (pCallback->GetwxLuaState().GetRefData() != this) // don't unref us pCallback->ClearwxLuaState(); *************** *** 1036,1041 **** } ! m_wxlStateData->m_eventHandlerList.Clear(); ! m_wxlStateData->m_destroyHandlerList.Clear(); } --- 1037,1042 ---- } ! m_wxlStateData->m_callbackList.Clear(); ! m_wxlStateData->m_winDestroyCallbackList.Clear(); } *************** *** 1286,1289 **** --- 1287,1296 ---- } + void wxLuaState::SetInEventType(wxEventType eventType) + { + wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); + M_WXLSTATEDATA->m_wxlStateData->m_inEventType = eventType; + } + void wxLuaState::SetEventHandler(wxEvtHandler *evtHandler) { *************** *** 1703,1707 **** } ! wxLuaBinding* wxLuaState::GetLuaBinding(const wxString& nameSpace) const { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); --- 1710,1714 ---- } ! wxLuaBinding* wxLuaState::GetLuaBinding(const wxString& bindingName) const { wxCHECK_MSG(GetRefData() != NULL, NULL, wxT("Invalid wxLuaState")); *************** *** 1710,1714 **** { wxLuaBinding* binding = node->GetData(); ! if (binding->GetLuaNamespace() == nameSpace) return binding; } --- 1717,1721 ---- { wxLuaBinding* binding = node->GetData(); ! if (binding->GetBindingName() == bindingName) return binding; } *************** *** 1878,1900 **** // memory tracking functions ! void wxLuaState::AddToTrackedMemoryList(wxObject *pObject) { ! wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList[(long)pObject] = (long)pObject; } ! void wxLuaState::AddToTrackedMemoryList(long obj_ptr, wxObject *pObject) { wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList[obj_ptr] = (long)pObject; } ! bool wxLuaState::RemoveTrackedMemory(void *pObject, bool fDelete) { wxCHECK_MSG(Ok() && pObject, false, wxT("Invalid wxLuaState or object")); ! wxLongToLongHashMap::iterator it = M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList.find((long) pObject); ! if (it != M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList.end()) { // always delete the object for the case where it's encapsulated --- 1885,1906 ---- // memory tracking functions ! void wxLuaState::AddTrackedObject(wxObject *pObject) { ! AddTrackedObject((long)pObject, pObject); } ! void wxLuaState::AddTrackedObject(long obj_ptr, wxObject *pObject) { wxCHECK_RET(Ok() && pObject, wxT("Invalid wxLuaState or wxObject to track")); ! M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects[obj_ptr] = (long)pObject; } ! bool wxLuaState::RemoveTrackedObject(void *pObject, bool fDelete) { wxCHECK_MSG(Ok() && pObject, false, wxT("Invalid wxLuaState or object")); ! wxLongToLongHashMap::iterator it = M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects.find((long) pObject); ! if (it != M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects.end()) { // always delete the object for the case where it's encapsulated *************** *** 1906,1910 **** // remove the item from being tracked ! M_WXLSTATEDATA->m_wxlStateData->m_pTrackedList.erase(it); return true; --- 1912,1916 ---- // remove the item from being tracked ! M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects.erase(it); return true; *************** *** 1914,1918 **** } ! void wxLuaState::AddToTrackedWindowList(wxWindow *pWindow) { wxCHECK_RET(Ok() && pWindow, wxT("Invalid wxLuaState or wxWindow")); --- 1920,1930 ---- } ! wxLongToLongHashMap* wxLuaState::GetTrackedObjects() ! { ! wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_trackedObjects; ! } ! ! void wxLuaState::AddTrackedWindow(wxWindow *pWindow) { wxCHECK_RET(Ok() && pWindow, wxT("Invalid wxLuaState or wxWindow")); *************** *** 1930,1937 **** } ! void wxLuaState::RemoveTrackedWindow(wxWindow *pWindow) { ! wxCHECK_RET(Ok() && pWindow, wxT("Invalid wxLuaState or wxWindow")); ! M_WXLSTATEDATA->m_wxlStateData->m_windowList.DeleteObject(pWindow); } --- 1942,1949 ---- } ! bool wxLuaState::RemoveTrackedWindow(wxWindow *pWindow) { ! wxCHECK_MSG(Ok() && pWindow, false, wxT("Invalid wxLuaState or wxWindow")); ! return M_WXLSTATEDATA->m_wxlStateData->m_windowList.DeleteObject(pWindow); } *************** *** 1962,1995 **** } ! void wxLuaState::AddTrackedEventHandler(wxEvtHandler* evtHandler) { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! M_WXLSTATEDATA->m_wxlStateData->m_eventHandlerList.Append(evtHandler); } ! bool wxLuaState::RemoveTrackedEventHandler(wxEvtHandler* evtHandler) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return M_WXLSTATEDATA->m_wxlStateData->m_eventHandlerList.DeleteObject(evtHandler); } ! wxList* wxLuaState::GetTrackedEventHandlerList() { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_eventHandlerList; } ! void wxLuaState::AddTrackedDestroyEventHandler(wxEvtHandler* evtHandler) { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! M_WXLSTATEDATA->m_wxlStateData->m_destroyHandlerList.Append(evtHandler); } ! bool wxLuaState::RemoveTrackedDestroyEventHandler(wxEvtHandler* evtHandler) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return M_WXLSTATEDATA->m_wxlStateData->m_destroyHandlerList.DeleteObject(evtHandler); } ! wxList* wxLuaState::GetTrackedDestroyEventHandlerList() { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_destroyHandlerList; } --- 1974,2007 ---- } ! void wxLuaState::AddTrackedCallback(wxLuaCallback* callback) { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! M_WXLSTATEDATA->m_wxlStateData->m_callbackList.Append(callback); } ! bool wxLuaState::RemoveTrackedCallback(wxLuaCallback* callback) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return M_WXLSTATEDATA->m_wxlStateData->m_callbackList.DeleteObject(callback); } ! wxList* wxLuaState::GetTrackedCallbackList() { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_callbackList; } ! void wxLuaState::AddTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback) { wxCHECK_RET(Ok(), wxT("Invalid wxLuaState")); ! M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList.Append(callback); } ! bool wxLuaState::RemoveTrackedWinDestroyCallback(wxLuaWinDestroyCallback* callback) { wxCHECK_MSG(Ok(), false, wxT("Invalid wxLuaState")); ! return M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList.DeleteObject(callback); } ! wxList* wxLuaState::GetTrackedWinDestroyCallbackList() { wxCHECK_MSG(Ok(), NULL, wxT("Invalid wxLuaState")); ! return &M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList; } *************** *** 2259,2267 **** // check to make sure that we're not trying to attach another destroy callback bool already_handled = false; ! wxNode* node = M_WXLSTATEDATA->m_wxlStateData->m_destroyHandlerList.GetFirst(); while (node) { ! wxLuaDestroyCallback *pCallback = (wxLuaDestroyCallback *)node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaCallback")); if (pCallback->GetEvtHandler() == win) { --- 2271,2279 ---- // check to make sure that we're not trying to attach another destroy callback bool already_handled = false; ! wxNode* node = M_WXLSTATEDATA->m_wxlStateData->m_winDestroyCallbackList.GetFirst(); while (node) { ! wxLuaWinDestroyCallback *pCallback = (wxLuaWinDestroyCallback *)node->GetData(); ! wxCHECK_RET(pCallback, wxT("Invalid wxLuaWinDestroyCallback")); if (pCallback->GetEvtHandler() == win) { *************** *** 2277,2287 **** { handled = true; ! wxLuaDestroyCallback *pCallback = new wxLuaDestroyCallback(*this, ! win->GetId(), ! (wxEvtHandler *) win, ! tag); if (pCallback == NULL) { ! terror("wxLua: Out of memory"); } } --- 2289,2298 ---- { handled = true; ! wxLuaWinDestroyCallback *pCallback = ! new wxLuaWinDestroyCallback(*this, win->GetId(), ! (wxEvtHandler*)win, tag); if (pCallback == NULL) { ! terror("wxLua: Out of memory creating wxLuaWinDestroyCallback."); } } Index: wxlbind.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** wxlbind.cpp 12 Dec 2006 07:09:41 -0000 1.46 --- wxlbind.cpp 14 Dec 2006 01:01:26 -0000 1.47 *************** *** 231,237 **** // ---------------------------------------------------------------------------- ! void LUACALL wxLua_AddToTrackedMemoryList(wxLuaState& wxlState, wxObject *pObject) { ! wxlState.AddToTrackedMemoryList(pObject); } --- 231,237 ---- // ---------------------------------------------------------------------------- ! void LUACALL wxLua_AddTrackedObject(wxLuaState& wxlState, wxObject *pObject) { ! wxlState.AddTrackedObject(pObject); } *************** *** 268,272 **** //tracked = ! wxlState.RemoveTrackedMemory((void*)key, true); // delete from m_pTrackedList wxLongToLongHashMap& pDerivedList = wxlState.GetLuaStateData()->m_pDerivedList; --- 268,272 ---- //tracked = ! wxlState.RemoveTrackedObject((void*)key, true); // delete from m_pTrackedList wxLongToLongHashMap& pDerivedList = wxlState.GetLuaStateData()->m_pDerivedList; *************** *** 460,464 **** } } ! (*pHashTable)[index] = (long)new wxLuaObject(L, 3); } } --- 460,464 ---- } } ! (*pHashTable)[index] = (long)new wxLuaObject(wxlState, 3); } } Index: wxlcallb.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlcallb.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** wxlcallb.cpp 12 Dec 2006 07:09:41 -0000 1.22 --- wxlcallb.cpp 14 Dec 2006 01:01:26 -0000 1.23 *************** *** 1,5 **** ///////////////////////////////////////////////////////////////////////////// ! // Name: wxLuaCallback ! // Purpose: A simple class for a C++ wxWidgets program to embed wxLua // Author: Francis Irving // Created: 11/05/2002 --- 1,5 ---- ///////////////////////////////////////////////////////////////////////////// ! // Name: wxlcallb.cpp ! // Purpose: wxLuaCallback and wxLuaWinDestroyCallback // Author: Francis Irving // Created: 11/05/2002 *************** *** 21,36 **** #include "wxlua/include/wxlcallb.h" - //extern int s_wxluatag_wxEvent; - //----------------------------------------------------------------------------- // wxLuaCallback //----------------------------------------------------------------------------- ! IMPLEMENT_ABSTRACT_CLASS(wxLuaCallback, wxEvtHandler) ! ! wxLuaCallback::wxLuaCallback( const wxLuaState& state, int theRoutine, ! wxWindowID winId, wxWindowID lastId, ! wxEventType eventType, wxEvtHandler *pEvtHandler ) ! : wxEvtHandler(), m_wxlState(state), m_pHandler(pEvtHandler), m_id(winId), m_lastId(lastId), m_eventType(eventType) --- 21,33 ---- #include "wxlua/include/wxlcallb.h" //----------------------------------------------------------------------------- // wxLuaCallback //----------------------------------------------------------------------------- + IMPLEMENT_ABSTRACT_CLASS(wxLuaCallback, wxObject) ! wxLuaCallback::wxLuaCallback(const wxLuaState& state, int lua_func_stack_idx, ! wxWindowID winId, wxWindowID lastId, ! wxEventType eventType, wxEvtHandler *pEvtHandler) ! : wxObject(), m_wxlState(state), m_pHandler(pEvtHandler), m_id(winId), m_lastId(lastId), m_eventType(eventType) *************** *** 38,42 **** wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); ! m_routine = m_wxlState.tinsert(theRoutine); pEvtHandler->Connect( winId, lastId, eventType, --- 35,40 ---- wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); ! // create a reference to the lua function ! m_routine = m_wxlState.tinsert(lua_func_stack_idx); pEvtHandler->Connect( winId, lastId, eventType, *************** *** 44,48 **** this); ! m_wxlState.AddTrackedEventHandler(this); } --- 42,46 ---- this); ! m_wxlState.AddTrackedCallback(this); } *************** *** 54,58 **** m_wxlState.tremove(m_routine); // delete the reference to this handler ! m_wxlState.RemoveTrackedEventHandler(this); } } --- 52,56 ---- m_wxlState.tremove(m_routine); // delete the reference to this handler ! m_wxlState.RemoveTrackedCallback(this); } } *************** *** 68,72 **** wxLuaState wxlState(theCallback->GetwxLuaState()); ! wxlState.GetLuaStateRefData()->m_wxlStateData->m_inEventType = event.GetEventType(); if (event.GetEventType() == wxEVT_DESTROY) --- 66,70 ---- wxLuaState wxlState(theCallback->GetwxLuaState()); ! wxlState.SetInEventType(event.GetEventType()); if (event.GetEventType() == wxEVT_DESTROY) *************** *** 75,79 **** wxlState.RemoveTrackedWindow((wxWindow*)event.GetEventObject()); // delete the reference to this handler since we're clearing it ! wxlState.RemoveTrackedEventHandler(theCallback); // Disconnect all callbacks associated with this window's evthandler --- 73,77 ---- wxlState.RemoveTrackedWindow((wxWindow*)event.GetEventObject()); // delete the reference to this handler since we're clearing it ! wxlState.RemoveTrackedCallback(theCallback); // Disconnect all callbacks associated with this window's evthandler *************** *** 82,89 **** wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); ! wxNode* node = wxlState.GetTrackedEventHandlerList()->GetFirst(); while (node) { ! wxLuaCallback *pCallback = (wxLuaCallback *) node->GetData(); if ((pCallback != NULL) && (pCallback->GetEvtHandler() == evtHandler)) --- 80,87 ---- wxEvtHandler *evtHandler = ((wxWindow*)event.GetEventObject())->GetEventHandler(); ! wxNode* node = wxlState.GetTrackedCallbackList()->GetFirst(); while (node) { ! wxLuaCallback *pCallback = (wxLuaCallback *)node->GetData(); if ((pCallback != NULL) && (pCallback->GetEvtHandler() == evtHandler)) *************** *** 92,96 **** wxNode* pc_node = node; // remember current node node = node->GetNext(); ! wxlState.GetTrackedEventHandlerList()->Erase(pc_node); pCallback->ClearwxLuaState(); --- 90,94 ---- wxNode* pc_node = node; // remember current node node = node->GetNext(); ! wxlState.GetTrackedCallbackList()->Erase(pc_node); pCallback->ClearwxLuaState(); *************** *** 103,107 **** theCallback->CallFunction(&event); ! wxlState.GetLuaStateRefData()->m_wxlStateData->m_inEventType = wxEVT_NULL; } --- 101,105 ---- theCallback->CallFunction(&event); ! wxlState.SetInEventType(wxEVT_NULL); } *************** *** 143,156 **** // ---------------------------------------------------------------------------- ! // wxLuaDestroyCallback // ---------------------------------------------------------------------------- ! IMPLEMENT_ABSTRACT_CLASS(wxLuaDestroyCallback, wxEvtHandler) ! ! wxLuaDestroyCallback::wxLuaDestroyCallback(const wxLuaState& state, ! wxWindowID id, wxEvtHandler *pHandler, ! int iTag) ! : wxEvtHandler(), m_wxlState(state), ! m_pHandler(pHandler), m_id(id) { wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); --- 141,153 ---- // ---------------------------------------------------------------------------- ! // wxLuaWinDestroyCallback // ---------------------------------------------------------------------------- + IMPLEMENT_ABSTRACT_CLASS(wxLuaWinDestroyCallback, wxObject) ! wxLuaWinDestroyCallback::wxLuaWinDestroyCallback(const wxLuaState& state, ! wxWindowID id, wxEvtHandler *pHandler, ! int iTag) ! :wxObject(), m_wxlState(state), ! m_pHandler(pHandler), m_id(id) { wxCHECK_RET(m_wxlState.Ok(), wxT("Invalid wxLuaState")); *************** *** 158,162 **** // allocate a LUA proxy for the object ! const void **ptr = (const void **) lua_newuserdata(L, sizeof(void *)); if (ptr != NULL) { --- 155,159 ---- // allocate a LUA proxy for the object ! const void **ptr = (const void **)lua_newuserdata(L, sizeof(void *)); if (ptr != NULL) { *************** *** 168,174 **** { if (lua_setmetatable(L, -2) == 0) ! { ! m_wxlState.terror("wxLua: Unable to set metatable"); ! } } --- 165,169 ---- { if (lua_setmetatable(L, -2) == 0) ! m_wxlState.terror("wxLua: Unable to set metatable of proxy in wxLuaWinDestroyCallback."); } *************** *** 184,219 **** } ! m_wxlState.AddTrackedDestroyEventHandler(this); // connect the event handler pHandler->Connect(id, wxEVT_DESTROY, ! (wxObjectEventFunction)&wxLuaDestroyCallback::EventHandler, this); } else { ! m_wxlState.terror("wxLua: Out of memory"); } } ! wxLuaDestroyCallback::~wxLuaDestroyCallback() { if (m_wxlState.Ok()) ! m_wxlState.RemoveTrackedDestroyEventHandler(this); } ! void wxLuaDestroyCallback::EventHandler(wxWindowDestroyEvent& event) { ! wxLuaDestroyCallback *theCallback = (wxLuaDestroyCallback *) event.m_callbackUserData; if (theCallback && (((wxEvtHandler*)event.GetEventObject()) == theCallback->m_pHandler)) { ! theCallback->OnDestroy(); } ! ! event.Skip(); } ! void wxLuaDestroyCallback::OnDestroy() { // FIXME - Is it an error to receive an event after you've deleted lua? // probably not if lua is getting shutdown --- 179,216 ---- } ! m_wxlState.AddTrackedWinDestroyCallback(this); // connect the event handler pHandler->Connect(id, wxEVT_DESTROY, ! (wxObjectEventFunction)&wxLuaWinDestroyCallback::EventHandler, this); } else { ! m_wxlState.terror("wxLua: Out of memory trying to create wxLuaWinDestroyCallback."); } } ! wxLuaWinDestroyCallback::~wxLuaWinDestroyCallback() { if (m_wxlState.Ok()) ! m_wxlState.RemoveTrackedWinDestroyCallback(this); } ! void wxLuaWinDestroyCallback::EventHandler(wxWindowDestroyEvent& event) { ! wxLuaWinDestroyCallback *theCallback = (wxLuaWinDestroyCallback *)event.m_callbackUserData; if (theCallback && (((wxEvtHandler*)event.GetEventObject()) == theCallback->m_pHandler)) { ! theCallback->OnDestroy(event); } ! else ! event.Skip(); } ! void wxLuaWinDestroyCallback::OnDestroy(wxWindowDestroyEvent& event) { + event.Skip(); + // FIXME - Is it an error to receive an event after you've deleted lua? // probably not if lua is getting shutdown |