From: Mattia B. <mat...@li...> - 2005-01-05 14:27:01
|
On Tue, 4 Jan 2005 14:50:53 -0500 Cheetah <fa...@gm...> wrote: > On Thu, 30 Dec 2004 20:43:49 -0500, Cheetah <fa...@gm...> wrote: > > After doing some more detailed digging and experimenting, it seems > > that only the renderer needs to be forcibly preserved. Also, > > wxWidgets itself seems to do some refcounting of the editors and > > renderers, but that all seems to be in order, or at least the same > > between the two, and likewise in the wxPerl sourcecode. > > I think I've shone some more light on the problem. The code for > SetDefaultRenderer/Editor calls IncRef to prevent the object from > being deleted when the perl object goes out of scope. However, > RegisterDataType does not, nor does the underlying wxWidgets code. > So, I think something like the following should help: > > --- ../ascii-debug/Wx-0.21/ext/grid/XS/Grid.xs 2004-11-23 > 17:10:54.000000000 -0500 > +++ Wx-0.21/ext/grid/XS/Grid.xs 2005-01-04 14:35:57.566713900 -0500 > @@ -621,6 +621,10 @@ > wxString typeName > wxGridCellRenderer* renderer > wxGridCellEditor* editor > + CODE: > + renderer->IncRef(); > + editor->IncRef(); > + THIS->RegisterDataType( typeName, renderer, editor ); > > void > wxGrid::SaveEditControlValue() > > I'm waiting for compiles to finish to test this. My rudimentary test > to see if I had the right idea was to change my custom grid/table > classes to temporarily do everything as strings instead of longs, and > then use the SetDefaultEditor/Renderer methods, which indeed made my > crashes go away. I added this to my local copy. I am just waiting for your OK to commit it. Thanks! Mattia |