From: John L. <jr...@us...> - 2007-08-22 20:17:15
|
Update of /cvsroot/wxlua/wxLua/modules/wxbind/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv25335/wxLua/modules/wxbind/src Modified Files: wxxml_xml.cpp Log Message: Fix SF bug 1776184, XML binding crashes, by adding %gc and %ungc for functions that either take ownership or release a pointer. Index: wxxml_xml.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxbind/src/wxxml_xml.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** wxxml_xml.cpp 1 Aug 2007 19:15:37 -0000 1.3 --- wxxml_xml.cpp 22 Aug 2007 20:17:09 -0000 1.4 *************** *** 32,36 **** static int LUACALL wxLua_wxXmlNode_AddChild(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_AddChild[1] = {{ wxLua_wxXmlNode_AddChild, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_AddChild }}; ! // void AddChild(wxXmlNode *child) static int LUACALL wxLua_wxXmlNode_AddChild(lua_State *L) { --- 32,36 ---- static int LUACALL wxLua_wxXmlNode_AddChild(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_AddChild[1] = {{ wxLua_wxXmlNode_AddChild, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_AddChild }}; ! // void AddChild(%ungc wxXmlNode *child) static int LUACALL wxLua_wxXmlNode_AddChild(lua_State *L) { *************** *** 38,41 **** --- 38,42 ---- // wxXmlNode child wxXmlNode * child = (wxXmlNode *)wxlState.GetUserDataType(2, s_wxluatag_wxXmlNode); + if (wxlState.IsTrackedObject(child)) wxlState.RemoveTrackedObject(child, wxLuaState::UNDELETE_OBJECT); // get this wxXmlNode * self = (wxXmlNode *)wxlState.GetUserDataType(1, s_wxluatag_wxXmlNode); *************** *** 49,53 **** static int LUACALL wxLua_wxXmlNode_AddProperty1(lua_State *L); // static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_AddProperty1[1] = {{ wxLua_wxXmlNode_AddProperty1, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_AddProperty1 }}; ! // void AddProperty(wxXmlProperty *prop) static int LUACALL wxLua_wxXmlNode_AddProperty1(lua_State *L) { --- 50,54 ---- static int LUACALL wxLua_wxXmlNode_AddProperty1(lua_State *L); // static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_AddProperty1[1] = {{ wxLua_wxXmlNode_AddProperty1, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_AddProperty1 }}; ! // void AddProperty(%ungc wxXmlProperty *prop) static int LUACALL wxLua_wxXmlNode_AddProperty1(lua_State *L) { *************** *** 55,58 **** --- 56,60 ---- // wxXmlProperty prop wxXmlProperty * prop = (wxXmlProperty *)wxlState.GetUserDataType(2, s_wxluatag_wxXmlProperty); + if (wxlState.IsTrackedObject(prop)) wxlState.RemoveTrackedObject(prop, wxLuaState::UNDELETE_OBJECT); // get this wxXmlNode * self = (wxXmlNode *)wxlState.GetUserDataType(1, s_wxluatag_wxXmlNode); *************** *** 300,304 **** static int LUACALL wxLua_wxXmlNode_InsertChild(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_InsertChild[1] = {{ wxLua_wxXmlNode_InsertChild, WXLUAMETHOD_METHOD, 3, 3, s_wxluatagArray_wxLua_wxXmlNode_InsertChild }}; ! // void InsertChild(wxXmlNode *child, wxXmlNode *before_node) static int LUACALL wxLua_wxXmlNode_InsertChild(lua_State *L) { --- 302,306 ---- static int LUACALL wxLua_wxXmlNode_InsertChild(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_InsertChild[1] = {{ wxLua_wxXmlNode_InsertChild, WXLUAMETHOD_METHOD, 3, 3, s_wxluatagArray_wxLua_wxXmlNode_InsertChild }}; ! // void InsertChild(%ungc wxXmlNode *child, wxXmlNode *before_node) static int LUACALL wxLua_wxXmlNode_InsertChild(lua_State *L) { *************** *** 308,311 **** --- 310,314 ---- // wxXmlNode child wxXmlNode * child = (wxXmlNode *)wxlState.GetUserDataType(2, s_wxluatag_wxXmlNode); + if (wxlState.IsTrackedObject(child)) wxlState.RemoveTrackedObject(child, wxLuaState::UNDELETE_OBJECT); // get this wxXmlNode * self = (wxXmlNode *)wxlState.GetUserDataType(1, s_wxluatag_wxXmlNode); *************** *** 319,323 **** static int LUACALL wxLua_wxXmlNode_RemoveChild(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_RemoveChild[1] = {{ wxLua_wxXmlNode_RemoveChild, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_RemoveChild }}; ! // bool RemoveChild(wxXmlNode *child) static int LUACALL wxLua_wxXmlNode_RemoveChild(lua_State *L) { --- 322,327 ---- static int LUACALL wxLua_wxXmlNode_RemoveChild(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_RemoveChild[1] = {{ wxLua_wxXmlNode_RemoveChild, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_RemoveChild }}; ! // %override wxLua_wxXmlNode_RemoveChild ! // bool RemoveChild(%gc wxXmlNode *child) static int LUACALL wxLua_wxXmlNode_RemoveChild(lua_State *L) { *************** *** 330,333 **** --- 334,341 ---- // call RemoveChild returns = (self->RemoveChild(child)); + + if (returns && !wxlState.IsTrackedObject(child)) + wxlState.AddTrackedObject((long)child, new wxLua_wxObject_wxXmlNode(child)); + // push the result flag lua_pushboolean(L, returns); *************** *** 336,343 **** } static wxLuaArgTag s_wxluatagArray_wxLua_wxXmlNode_SetChildren[] = { &s_wxluatag_wxXmlNode, &s_wxluatag_wxXmlNode, NULL }; static int LUACALL wxLua_wxXmlNode_SetChildren(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_SetChildren[1] = {{ wxLua_wxXmlNode_SetChildren, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_SetChildren }}; ! // void SetChildren(wxXmlNode *child) static int LUACALL wxLua_wxXmlNode_SetChildren(lua_State *L) { --- 344,352 ---- } + static wxLuaArgTag s_wxluatagArray_wxLua_wxXmlNode_SetChildren[] = { &s_wxluatag_wxXmlNode, &s_wxluatag_wxXmlNode, NULL }; static int LUACALL wxLua_wxXmlNode_SetChildren(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_SetChildren[1] = {{ wxLua_wxXmlNode_SetChildren, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_SetChildren }}; ! // void SetChildren(%ungc wxXmlNode *child) static int LUACALL wxLua_wxXmlNode_SetChildren(lua_State *L) { *************** *** 345,348 **** --- 354,358 ---- // wxXmlNode child wxXmlNode * child = (wxXmlNode *)wxlState.GetUserDataType(2, s_wxluatag_wxXmlNode); + if (wxlState.IsTrackedObject(child)) wxlState.RemoveTrackedObject(child, wxLuaState::UNDELETE_OBJECT); // get this wxXmlNode * self = (wxXmlNode *)wxlState.GetUserDataType(1, s_wxluatag_wxXmlNode); *************** *** 424,428 **** static int LUACALL wxLua_wxXmlNode_SetProperties(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_SetProperties[1] = {{ wxLua_wxXmlNode_SetProperties, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_SetProperties }}; ! // void SetProperties(wxXmlProperty *prop) static int LUACALL wxLua_wxXmlNode_SetProperties(lua_State *L) { --- 434,438 ---- static int LUACALL wxLua_wxXmlNode_SetProperties(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_SetProperties[1] = {{ wxLua_wxXmlNode_SetProperties, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlNode_SetProperties }}; ! // void SetProperties(%ungc wxXmlProperty *prop) static int LUACALL wxLua_wxXmlNode_SetProperties(lua_State *L) { *************** *** 430,433 **** --- 440,444 ---- // wxXmlProperty prop wxXmlProperty * prop = (wxXmlProperty *)wxlState.GetUserDataType(2, s_wxluatag_wxXmlProperty); + if (wxlState.IsTrackedObject(prop)) wxlState.RemoveTrackedObject(prop, wxLuaState::UNDELETE_OBJECT); // get this wxXmlNode * self = (wxXmlNode *)wxlState.GetUserDataType(1, s_wxluatag_wxXmlNode); *************** *** 474,477 **** --- 485,489 ---- static int LUACALL wxLua_wxXmlNode_constructor2(lua_State *L); // static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_constructor2[1] = {{ wxLua_wxXmlNode_constructor2, WXLUAMETHOD_CONSTRUCTOR, 6, 6, s_wxluatagArray_wxLua_wxXmlNode_constructor2 }}; + // %override wxLua_wxXmlNode_constructor2 // wxXmlNode(wxXmlNode *parent, wxXmlNodeType type, const wxString& name, const wxString& content, wxXmlProperty *props, wxXmlNode *next) static int LUACALL wxLua_wxXmlNode_constructor2(lua_State *L) *************** *** 495,499 **** returns = new wxXmlNode(parent, type, name, content, props, next); // add to tracked memory list ! wxlState.AddTrackedObject((long)returns, new wxLua_wxObject_wxXmlNode((wxXmlNode *)returns)); // push the constructed class pointer wxlState.PushUserDataType(s_wxluatag_wxXmlNode, returns); --- 507,512 ---- returns = new wxXmlNode(parent, type, name, content, props, next); // add to tracked memory list ! if (parent == NULL) ! wxlState.AddTrackedObject((long)returns, new wxLua_wxObject_wxXmlNode((wxXmlNode *)returns)); // push the constructed class pointer wxlState.PushUserDataType(s_wxluatag_wxXmlNode, returns); *************** *** 502,509 **** } static wxLuaArgTag s_wxluatagArray_wxLua_wxXmlNode_constructor1[] = { &s_wxluaarg_Integer, &s_wxluaarg_String, &s_wxluaarg_String, NULL }; static int LUACALL wxLua_wxXmlNode_constructor1(lua_State *L); // static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_constructor1[1] = {{ wxLua_wxXmlNode_constructor1, WXLUAMETHOD_CONSTRUCTOR, 2, 3, s_wxluatagArray_wxLua_wxXmlNode_constructor1 }}; ! // wxXmlNode(wxXmlNodeType type, const wxString& name, const wxString& content = wxEmptyString) static int LUACALL wxLua_wxXmlNode_constructor1(lua_State *L) { --- 515,523 ---- } + static wxLuaArgTag s_wxluatagArray_wxLua_wxXmlNode_constructor1[] = { &s_wxluaarg_Integer, &s_wxluaarg_String, &s_wxluaarg_String, NULL }; static int LUACALL wxLua_wxXmlNode_constructor1(lua_State *L); // static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlNode_constructor1[1] = {{ wxLua_wxXmlNode_constructor1, WXLUAMETHOD_CONSTRUCTOR, 2, 3, s_wxluatagArray_wxLua_wxXmlNode_constructor1 }}; ! // wxXmlNode(wxXmlNodeType type, const wxString& name, const wxString& content = "") static int LUACALL wxLua_wxXmlNode_constructor1(lua_State *L) { *************** *** 513,517 **** // get number of arguments int argCount = lua_gettop(L); ! // const wxString content = wxEmptyString const wxString content = (argCount >= 3 ? wxlState.GetwxStringType(3) : wxString(wxEmptyString)); // const wxString name --- 527,531 ---- // get number of arguments int argCount = lua_gettop(L); ! // const wxString content = "" const wxString content = (argCount >= 3 ? wxlState.GetwxStringType(3) : wxString(wxEmptyString)); // const wxString name *************** *** 1011,1015 **** static int LUACALL wxLua_wxXmlDocument_SetRoot(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlDocument_SetRoot[1] = {{ wxLua_wxXmlDocument_SetRoot, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlDocument_SetRoot }}; ! // void SetRoot(wxXmlNode *node); static int LUACALL wxLua_wxXmlDocument_SetRoot(lua_State *L) { --- 1025,1029 ---- static int LUACALL wxLua_wxXmlDocument_SetRoot(lua_State *L); static wxLuaBindCFunc s_wxluafunc_wxLua_wxXmlDocument_SetRoot[1] = {{ wxLua_wxXmlDocument_SetRoot, WXLUAMETHOD_METHOD, 2, 2, s_wxluatagArray_wxLua_wxXmlDocument_SetRoot }}; ! // void SetRoot(%ungc wxXmlNode *node); static int LUACALL wxLua_wxXmlDocument_SetRoot(lua_State *L) { *************** *** 1017,1020 **** --- 1031,1035 ---- // wxXmlNode node wxXmlNode * node = (wxXmlNode *)wxlState.GetUserDataType(2, s_wxluatag_wxXmlNode); + if (wxlState.IsTrackedObject(node)) wxlState.RemoveTrackedObject(node, wxLuaState::UNDELETE_OBJECT); // get this wxXmlDocument * self = (wxXmlDocument *)wxlState.GetUserDataType(1, s_wxluatag_wxXmlDocument); |