On Sun, Dec 7, 2008 at 1:03 PM, arpin <[EMAIL PROTECTED]> wrote: > I have tried to resolve this crash but I am getting nowhere. > ----------------------------------------- > f = wx.wxFrame(wx.NULL, -1, "Hello") > > gridtable = wx.wxLuaGridTableBase(); > function gridtable:GetNumberCols () return 1 end > function gridtable:GetNumberRows () return 1 end > function gridtable:GetValue (row, col) return 99 end > grid = wx.wxGrid(f, wx.wxID_ANY) > grid:SetTable(gridtable) > gridtable:SetView( grid ) > > f:Show(true) > --------------------------------------- > > The problem is in thje function gridtable:GetValue the return type is wrong it > should be string instead of a number. > > It seems that the GetwxStringType is checking for the argument of a function > instead of a return value. I really do not understand the code enough to find > a fix. I work on it for a number of hours and finally gave up. > > I hope you can figure this out.
Thanks for the code snippet. It makes duplicating the error much easier. I fixed a little problem in that if Lua has no stack (not in a Lua function) that we'd crash hard. This was because wxLua's error function would try to fill a lua_Debug struct to create a nice error message, but a call to lua_getinfo(L, lua_Debug) would segfault. The added check was easy so we don't crash... but none the less the program still exits since Lua calls it's panic() function if lua_error() is called without a stack. The reason why Lua doesn't have a stack is not a fault or problem, it's that the C++ virtual function is being called from C++ code which runs the Lua code (your GetValue() function) which returns ok, but when we try to get a string off the top of the stack, we get a number so we error(). Again, I think this is fine, in that we have to notify the programmer that they're doing something wrong. Unfortunately, this is where Lua calls it's panic() function which calls the C function exit() that abruptly ends the program. So, long story short: You now get the message below and the program exits: PANIC: unprotected error in call to Lua API (wxLua: Expected a 'string' or 'wxString' for parameter -1, but got a 'number'. Function called: '?' This is woefully uninformative, in that it doesn't say where it happened because we can't get any help from Lua. I could write another set of functions or a flag to the current ones to NOT error, but rather just print() the error and continue. I have to think about if it's worth it in that I don't want the bindings to grow until they're too much for me to handle. =============== As a side note; you may want to use this form of the virtual functions so you can get at the 'self' function gridtable.GetValue (self, row, col) print(self, row, col); return '99' end Regards, John ------------------------------------------------------------------------------ SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. The future of the web can't happen without you. Join us at MIX09 to help pave the way to the Next Web now. Learn more and register at http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users