<div dir="ltr">On Tue, Jul 29, 2008 at 7:28 AM, Glen Holcomb <span dir="ltr">&lt;<a href="mailto:damnbigman@gmail.com">damnbigman@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr"><div><div></div><div class="Wj3C7c">On Tue, Jul 29, 2008 at 4:37 AM, Alex Fenton <span dir="ltr">&lt;<a href="mailto:alex@pressure.to" target="_blank">alex@pressure.to</a>&gt;</span> wrote:<br><div class="gmail_quote">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Glen<div><br>
<br>
Glen Holcomb wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In my application I have a few Grid objects in a Notebook. &nbsp;The Grid objects are populated via GridTableBase. &nbsp;Certain Grid cells need to have a choice interface (I&#39;m artificially enforcing foreign key constraints). &nbsp;All this works to the point where you try to edit the value for that cell. &nbsp;The choice box renders (i.e. the drop down arrow appears) then the application segfaults. &nbsp;Unfortunately I&#39;m stuck developing this in a Windows (XP) environment so I can&#39;t do much with the segfault. &nbsp;Any help would be most appreciated.<br>


</blockquote></div>
The problem here is the combination of GridTableBase and cell editors / renderers, which makes the memory management very tricky. It&#39;s noted as a bug here:<br>
<a href="http://rubyforge.org/tracker/index.php?func=detail&amp;aid=19187&amp;group_id=35&amp;atid=218" target="_blank">http://rubyforge.org/tracker/index.php?func=detail&amp;aid=19187&amp;group_id=35&amp;atid=218</a><br>


<br>
I don&#39;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)<br>


<br>
def get_attr(row, col, attr_kind)<br>
&nbsp;attr = Wx::GridCellAttr.new<br>
<br>
&nbsp;if @db_table == &quot;computers&quot; and col == 4<br>
 &nbsp; ## INSTEAD OF THIS<br>
 &nbsp; # attr.set_editor(Wx::GridCellChoiceEditor.new([&quot;CAD&quot;, &quot;GIS&quot;, &quot;CMT&quot;]))<br>
 &nbsp; ## TRY THIS<br>
 &nbsp; @editors ||= []<br>
 &nbsp; @editors &lt;&lt; Wx::GridCellChoiceEditor.new([&quot;CAD&quot;, &quot;GIS&quot;, &quot;CMT&quot;])<br>
 &nbsp; attr.set_editor(@editors.last)<br>
&nbsp;end<br>
<br>
&nbsp;attr<br>
end<br>
<br>
hth<br>
alex<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
wxruby-users mailing list<br>
<a href="mailto:wxruby-users@rubyforge.org" target="_blank">wxruby-users@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/wxruby-users" target="_blank">http://rubyforge.org/mailman/listinfo/wxruby-users</a><br>
</blockquote></div><br></div></div>Thanks Alex, I&#39;ll give that a shot and let you know how it turns out.<div class="Ih2E3d"><br clear="all"><br>-- <br>&quot;Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can&#39;t hear a word you&#39;re saying.&quot; <br>

<br>-Greg Graffin (Bad Religion)<br>
</div></div>
</blockquote></div><br>Okay back sooner than I thought, turns out I had the code here at home after all.&nbsp; Still no go.&nbsp; I tried GC.disable at the top of the app too and I get the same exact behavior.<br><br>The dropdown menu renders for a split second then it reverts to looking like the default cell.&nbsp; After that any attempt to interact with the app causes the segfault.<br>
<br>Oddly it doesn&#39;t segfault immediately and will infact continue to run until I click anywhere in the window.&nbsp; Returning focus to the app doesn&#39;t kill it either.<br clear="all"><br>-- <br>&quot;Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can't hear a word you're saying.&quot; <br>
<br>-Greg Graffin (Bad Religion)<br>
</div>