[wxruby-users] Segfault with GridCellChoiceEditor
Glen Holcomb
damnbigman at gmail.com
Tue Jul 29 09:42:48 EDT 2008
On Tue, Jul 29, 2008 at 7:34 AM, Glen Holcomb <damnbigman at gmail.com> wrote:
> On Tue, Jul 29, 2008 at 7:28 AM, Glen Holcomb <damnbigman at gmail.com>wrote:
>
>> On Tue, Jul 29, 2008 at 4:37 AM, Alex Fenton <alex at pressure.to> wrote:
>>
>>> Hi Glen
>>>
>>> Glen Holcomb wrote:
>>>
>>>> In my application I have a few Grid objects in a Notebook. The Grid
>>>> objects are populated via GridTableBase. Certain Grid cells need to have a
>>>> choice interface (I'm artificially enforcing foreign key constraints). All
>>>> this works to the point where you try to edit the value for that cell. The
>>>> choice box renders (i.e. the drop down arrow appears) then the application
>>>> segfaults. Unfortunately I'm stuck developing this in a Windows (XP)
>>>> environment so I can't do much with the segfault. Any help would be most
>>>> appreciated.
>>>>
>>> The problem here is the combination of GridTableBase and cell editors /
>>> renderers, which makes the memory management very tricky. It's noted as a
>>> bug here:
>>>
>>> http://rubyforge.org/tracker/index.php?func=detail&aid=19187&group_id=35&atid=218
>>>
>>> I don't know how to fix it in the library, but you should be able to work
>>> around it by storing the cell editor in an instance variable somewhere. Then
>>> ruby will mark it and preserve it from GC. From the code you posted on c.l.r
>>> (please do post code on this mailing list as well)
>>>
>>> def get_attr(row, col, attr_kind)
>>> attr = Wx::GridCellAttr.new
>>>
>>> if @db_table == "computers" and col == 4
>>> ## INSTEAD OF THIS
>>> # attr.set_editor(Wx::GridCellChoiceEditor.new(["CAD", "GIS", "CMT"]))
>>> ## TRY THIS
>>> @editors ||= []
>>> @editors << Wx::GridCellChoiceEditor.new(["CAD", "GIS", "CMT"])
>>> attr.set_editor(@editors.last)
>>> end
>>>
>>> attr
>>> end
>>>
>>> hth
>>> alex
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> wxruby-users mailing list
>>> wxruby-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/wxruby-users
>>>
>>
>> Thanks Alex, I'll give that a shot and let you know how it turns out.
>>
>> --
>> "Hey brother Christian with your high and mighty errand, Your actions
>> speak so loud, I can't hear a word you're saying."
>>
>> -Greg Graffin (Bad Religion)
>>
>
> Okay back sooner than I thought, turns out I had the code here at home
> after all. Still no go. I tried GC.disable at the top of the app too and I
> get the same exact behavior.
>
> The dropdown menu renders for a split second then it reverts to looking
> like the default cell. After that any attempt to interact with the app
> causes the segfault.
>
> Oddly it doesn't segfault immediately and will infact continue to run until
> I click anywhere in the window. Returning focus to the app doesn't kill it
> either.
>
> --
> "Hey brother Christian with your high and mighty errand, Your actions speak
> so loud, I can't hear a word you're saying."
>
> -Greg Graffin (Bad Religion)
>
Okay check that, I really need to be more thorough in my testing. I can
switch to other tabs in the notebook and edit cells in other Grids however
upon going back to the grid where I tried to edit the Choice Value
attempting to interact with any part of the grid causes death.
--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."
-Greg Graffin (Bad Religion)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080729/7d570fe6/attachment.html>
More information about the wxruby-users
mailing list