Update of /cvsroot/wxlua/wxLua/modules/wxlua/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv21115/wxLua/modules/wxlua/src
Modified Files:
wxlbind.cpp wxlstate.cpp
Log Message:
Don't crash in lua_getinfo(L, &lua_Debug) if we don't have a Lua stack.
Return "?" for the function name since there isn't one.
Index: wxlstate.cpp
===================================================================
RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp,v
retrieving revision 1.176
retrieving revision 1.177
diff -C2 -d -r1.176 -r1.177
*** wxlstate.cpp 5 Dec 2008 21:15:11 -0000 1.176
--- wxlstate.cpp 8 Dec 2008 05:17:11 -0000 1.177
***************
*** 308,312 ****
void LUACALL wxlua_argerrormsg(lua_State *L, const wxString& msg_)
{
! wxString funcArgs;
wxString argMsg = wxlua_getLuaArgsMsg(L, 1, lua_gettop(L));
--- 308,312 ----
void LUACALL wxlua_argerrormsg(lua_State *L, const wxString& msg_)
{
! wxString funcArgs(wxT("\n"));
wxString argMsg = wxlua_getLuaArgsMsg(L, 1, lua_gettop(L));
***************
*** 329,333 ****
}
! wxString msg = msg_ + wxT("\nFunction called: '") + argMsg + wxT("'\n") + funcArgs;
wxlua_error(L, msg);
}
--- 329,333 ----
}
! wxString msg = msg_ + wxT("\nFunction called: '") + argMsg + wxT("'") + funcArgs;
wxlua_error(L, msg);
}
Index: wxlbind.cpp
===================================================================
RCS file: /cvsroot/wxlua/wxLua/modules/wxlua/src/wxlbind.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -C2 -d -r1.120 -r1.121
*** wxlbind.cpp 26 Jan 2008 23:27:25 -0000 1.120
--- wxlbind.cpp 8 Dec 2008 05:17:11 -0000 1.121
***************
*** 791,796 ****
wxString wxlua_getLuaArgsMsg(lua_State* L, int start_stack_idx, int end_stack_idx)
{
! lua_Debug ar;
! lua_getstack(L, 0, &ar);
lua_getinfo(L, "n", &ar);
wxString funcName = lua2wx(ar.name);
--- 791,801 ----
wxString wxlua_getLuaArgsMsg(lua_State* L, int start_stack_idx, int end_stack_idx)
{
! lua_Debug ar = {0};
!
! // NOTE: We'd like to be able to give some info, however if we are not
! // running a Lua function the lua_Debug is empty and lua_getinfo() will panic.
! if (lua_getstack(L, 0, &ar) == 0) // returns 0 when called on a level greater than stack depth
! return wxT("?");
!
lua_getinfo(L, "n", &ar);
wxString funcName = lua2wx(ar.name);
|