On Fri, Mar 7, 2008 at 7:00 PM, Eero Pajarre <[EMAIL PROTECTED]> wrote: > On Fri, Mar 7, 2008 at 6:45 PM, John Labenski <[EMAIL PROTECTED]> wrote: > > > After looking into it a little more, I think the best solution is to > > use the %ungc tag in the interface file so that we have: > > wxGrid::SetCellEditor(int row, int col, %ungc wxGridCellEditor *editor) > > This means that Lua will not try to delete the editor and it's up to > > the wxGrid (actually wxGridCellAttr) to delete it by calling DecRef(). > > This sounds correct to me (based on wxwidgets code) >
Actually after looking more at the code, I think that doing a IncRef in Set operations is the better way, instead of this ungc-change. The problem is that if the same Editor or CellAttr is used multiple times it will lead program touching already deleted memory. The wxGrid will try to do a DecRef for each usage, which is not good. In C++ code I assume this is avoided by using IncRef in application code, or by not reusing CellAttr/Editor. As a related note, I think that the target should be, that IncRef/DecRef are not be part of wxLua Lua-API. Incorrectly using DecRef will lead to program crash, and I would rather have a "crash-proof-API". Eero ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users