From: John L. <jr...@us...> - 2006-05-03 22:52:21
|
Update of /cvsroot/wxlua/wxLua/modules/wxlua/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27806/wxLua/modules/wxlua/src Modified Files: wxlstate.cpp Log Message: don't track pushed wxWindows using EVT_DESTROY twice update geometry.i to 2.6.3 fix unary op - to use op_neg and fix binding operators in general update docs for op_neg Index: wxlstate.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** wxlstate.cpp 2 May 2006 22:46:53 -0000 1.63 --- wxlstate.cpp 3 May 2006 22:52:18 -0000 1.64 *************** *** 1983,2002 **** if (data != NULL) { ! wxWindow *win = NULL; // if the object we are referencing is derived from wxWindow if (IsDerivedClass(iTag, GetwxWindowTag())) // s_wxluatag_wxWindow { ! win = wxDynamicCast(data, wxWindow); if (win != NULL) { // Connect an object to the destroy event. ! wxLuaDestroyCallback *pCallback = new wxLuaDestroyCallback(*this, ! win->GetId(), ! (wxEvtHandler *) win, ! iTag); ! if (pCallback == NULL) { ! terror("wxLua: Out of memory"); } } --- 1983,2022 ---- if (data != NULL) { ! bool handled = false; // if the object we are referencing is derived from wxWindow if (IsDerivedClass(iTag, GetwxWindowTag())) // s_wxluatag_wxWindow { ! wxWindow* win = wxDynamicCast(data, wxWindow); if (win != NULL) { + // 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) + { + already_handled = true; + break; + } + + node = node->GetNext(); + } + // Connect an object to the destroy event. ! if (!already_handled) { ! handled = true; ! wxLuaDestroyCallback *pCallback = new wxLuaDestroyCallback(*this, ! win->GetId(), ! (wxEvtHandler *) win, ! iTag); ! if (pCallback == NULL) ! { ! terror("wxLua: Out of memory"); ! } } } *************** *** 2004,2010 **** // Otherwise handle normally ! if (win == NULL) tpushusertag(data, iTag); - } else --- 2024,2029 ---- // Otherwise handle normally ! if (!handled) tpushusertag(data, iTag); } else |