Ok, I've committed the change as you suggested to CVS for all the PCall functions.
Test Lua code: f = wx.wxFrame(wx.NULL, -1, "Hello") t = wx.wxLuaGridTableBase() t.GetNumberRows = function(self) return 1*x -- this is an error end g = wx.wxGrid(f, -1) g:SetTable(t) f:Show(true) I get this error (as expected): Running lua script 'untitled.lua' : Tue Dec 2 00:02:32 2008 Error: Lua: Error while running chunk [string "untitled.lua"]:7: attempt to perform arithmetic on global 'x' (a nil value) stack traceback: [string "untitled.lua"]:7: in function <[string "untitled.lua"]:6> [C]: in function 'SetTable' [string "untitled.lua"]:11: in main chunk Please let me know if it doesn't crash for you after this change. Also, what platform and compiler do you use. Regards, John On Mon, Dec 1, 2008 at 8:08 PM, John Labenski <[EMAIL PROTECTED]> wrote: > On Mon, Dec 1, 2008 at 9:18 AM, arpin <[EMAIL PROTECTED]> wrote: >> John Labenski <[EMAIL PROTECTED]> writes: >> >>> >>> if (m_wxlState.LuaPCall(1, 1) != 0) >>> m_wxlState.wxlua_Error("Error in function... blah blah, get error >>> string from stack..."); >> >> This code goes into no mans land. >> >> The original code reports the error on the console if the console is active >> and in a message box if it is not active. I think it is the right solution. > > The code above is basically identical to how it is now, what do you > mean it goes into no man's land? > > To be sure; I agree that there is a currently a problem in that we > really should check the return value of the pcall() and if there is an > error, not try to get values from the stack and show an error message, > but I do not want wxLua to crash. > > Take for example: modules/wxbind/src/wxadv_wxladv.cpp > and the function wxLuaGridTableBase::GetNumberRows() > > ... > m_wxlState.LuaPCall(1, 1); > numrows = (int)m_wxlState.GetNumberType(-1); > m_wxlState.lua_SetTop(nOldTop); > > If there is an error in the Lua code run by LuaPCall(), an error > message string is left on the stack. The next line (see > modues/wxlua/src/wxlstate.cpp); wxLuaState::GetNumberType(-1) calls > wxlua_getnumbertype() which fails since the item at the top of the > stack isn't a a number, wxlua_argerror() is called which calls > wxlua_argerrormsg() which finally calls wxlua_error(). > > Regards, > John > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users