I have a problem. 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. Thanks, Glen Holcomb -- "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) _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
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
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) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080729/a12dc0f2/attachment-0001.html>
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) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080729/0f451c30/attachment.html>
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>
Glen Holcomb wrote:> 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.OK - sorry it didn''t help - could you post a small but complete example that reproduces the issue so I can try it out and run it under a debugger please? thanks alex
On Tue, Jul 29, 2008 at 7:47 AM, Alex Fenton <alex at pressure.to> wrote:> Glen Holcomb wrote: > >> 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. >> > OK - sorry it didn''t help - could you post a small but complete example > that reproduces the issue so I can try it out and run it under a debugger > please? > > thanks > > alex > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >That''s a good question :) I''ll see what I can come up with. It might just be easier to send you the whole thing though as I''m using a sqlite database backend and Sequel, which could be contributing to or causing the problem. I''ll see if I can get something small that will re-create the problem though. -- "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/b724a1ef/attachment-0001.html>
On Tue, Jul 29, 2008 at 8:39 AM, Glen Holcomb <damnbigman at gmail.com> wrote:> On Tue, Jul 29, 2008 at 7:47 AM, Alex Fenton <alex at pressure.to> wrote: > >> Glen Holcomb wrote: >> >>> 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. >>> >> OK - sorry it didn''t help - could you post a small but complete example >> that reproduces the issue so I can try it out and run it under a debugger >> please? >> >> thanks >> >> alex >> >> >> >> _______________________________________________ >> wxruby-users mailing list >> wxruby-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/wxruby-users >> > > That''s a good question :) I''ll see what I can come up with. It might just > be easier to send you the whole thing though as I''m using a sqlite database > backend and Sequel, which could be contributing to or causing the problem. > > I''ll see if I can get something small that will re-create the problem > though. > > -- > "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 Alex, I''ve got it down to 225 lines, not short but I think it''s the shortest I can do without possibly trivializing the issue. I''m going to try attaching the file as it is a bit long and since I''ve stripped the code for adding db records (for brevity''s sake) I will need to attach a db file as well. I''m not sure if the list will allow attachments though so if not let me know. -Glen -- "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/05d29281/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: seg_repro.rb Type: application/octet-stream Size: 6758 bytes Desc: not available URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080729/05d29281/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: circadian.db Type: application/octet-stream Size: 8192 bytes Desc: not available URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080729/05d29281/attachment-0001.obj>
Glen Holcomb wrote:> Okay Alex, > > I''ve got it down to 225 lines, not short but I think it''s the shortest > I can do without possibly trivializing the issue. I''m going to try > attaching the file as it is a bit long and since I''ve stripped the > code for adding db records (for brevity''s sake) I will need to attach > a db file as well. I''m not sure if the list will allow attachments > though so if not let me know.Thanks Glen - I ran your code with a debug build which turned up what looks to be the source of the error: [Debug] 08:47:15: ../src/generic/grid.cpp(495): assert "m_control" failed in Show(): The wxGridCellEditor must be created first! Further poking with the debugger suggests that what''s happening is that somehow the editor is getting created but not correctly found when it comes to editing the cell. Unfortunately after an hour or two I couldn''t get to the root of the problem. My suggested workaround would be to dispense with GridTableBase and use Wx::Grid and Wx::Grid.set_editor directly to link your sequel model with the GUI. This may be slightly less elegant but shouldn''t involve any more code. The samples/grid/grid.rb demonstrates this. I''ve filed it as a bug on our tracker http://rubyforge.org/tracker/index.php?func=detail&aid=21389&group_id=35&atid=218 alex
On Wed, Jul 30, 2008 at 2:17 AM, Alex Fenton <alex at pressure.to> wrote:> Glen Holcomb wrote: > >> Okay Alex, >> >> I''ve got it down to 225 lines, not short but I think it''s the shortest I >> can do without possibly trivializing the issue. I''m going to try attaching >> the file as it is a bit long and since I''ve stripped the code for adding db >> records (for brevity''s sake) I will need to attach a db file as well. I''m >> not sure if the list will allow attachments though so if not let me know. >> > Thanks Glen - I ran your code with a debug build which turned up what looks > to be the source of the error: > > [Debug] 08:47:15: ../src/generic/grid.cpp(495): assert "m_control" failed > in Show(): The wxGridCellEditor must be created first! > > Further poking with the debugger suggests that what''s happening is that > somehow the editor is getting created but not correctly found when it comes > to editing the cell. Unfortunately after an hour or two I couldn''t get to > the root of the problem. > > My suggested workaround would be to dispense with GridTableBase and use > Wx::Grid and Wx::Grid.set_editor directly to link your sequel model with the > GUI. This may be slightly less elegant but shouldn''t involve any more code. > The samples/grid/grid.rb demonstrates this. > > I''ve filed it as a bug on our tracker > > http://rubyforge.org/tracker/index.php?func=detail&aid=21389&group_id=35&atid=218 > > > alex > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >Thanks Alex, I really appreciate all your effort on this. I''ll switch it to just Wx::Grid for now, I don''t think I''ll have any huge db tables at least not at first so it should work okay. -Glen -- "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/20080730/91bf8d6e/attachment.html>
I''m trying to create a TaskBarIcon with a right-click menu but I get a crash (in the evt_menu call) as soon as I right-click on the icon. Here''s the error message: C:/Projects/SoftPhone1/lib/SoftPhone.rb:35:in `process_event'': Swig director type mismatch in output value of type ''wxMenu *'' (TypeError) (The rescue doesn''t catch the error). Here''s the code (it doesn''t matter which variant of the evt_menu call I use): class SysTrayIcon < TaskBarIcon def initialize(parent) super() @softPhone = parent # soft_phone_frame icon = Icon.new("icons/phone.ico", BITMAP_TYPE_ICO) set_icon(icon, "Valcom VIP Page") end def create_popup_menu menu = Menu.new close_item = menu.append(101, ''Close VIP-Page'', ''Close VIP-Page'') evt_menu(close_item, :on_close) # evt_menu(close_item) {|event| on_close(event)} rescue Exception => e puts "create_popup_menu #{e}" end def on_close(event) @softphone.exit end end Any suggestions? Eric Rubin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20080730/64983909/attachment.html>
Eric Rubin wrote:> > I?m trying to create a TaskBarIcon with a right-click menu but I get a > crash (in the evt_menu call) as soon as I right-click on the icon. > > Here?s the error message: > > C:/Projects/SoftPhone1/lib/SoftPhone.rb:35:in `process_event'': Swig > director type mismatch in output value of type ''wxMenu *'' (TypeError) >I agree it''s not the most clear error message. What''s it telling you is that the method create_popup_menu is expected to return a value of type Wx::Menu, but you''re not doing this. In SWIG''s terminology, "director" methods are those, like create_popup_menu, where a ruby method is called on a certain event happening (in this case, right-clicking the icon) and you need to return a particular type (in this case, a Wx::Menu to be shown.> > (The rescue doesn?t catch the error). > > Here?s the code (it doesn?t matter which variant of the evt_menu call > I use): > > class SysTrayIcon < TaskBarIcon > > def initialize(parent) > > super() > > @softPhone = parent # soft_phone_frame > > icon = Icon.new("icons/phone.ico", BITMAP_TYPE_ICO) > > set_icon(icon, "Valcom VIP Page") > > end > > def create_popup_menu > > menu = Menu.new > > close_item = menu.append(101, ''Close VIP-Page'', ''Close VIP-Page'') > > evt_menu(close_item, :on_close) ># add this here, and delete the rescue clause return menu> > end > > def on_close(event) > > @softphone.exit > > end > > end >cheers alex
Thanks, That fixed it. Eric -----Original Message----- From: wxruby-users-bounces at rubyforge.org [mailto:wxruby-users-bounces at rubyforge.org] On Behalf Of Alex Fenton Sent: Wednesday, July 30, 2008 10:53 AM To: General discussion of wxRuby Subject: Re: [wxruby-users] Crash in evt_menu Eric Rubin wrote:> > I''m trying to create a TaskBarIcon with a right-click menu but I get a > crash (in the evt_menu call) as soon as I right-click on the icon. > > Here''s the error message: > > C:/Projects/SoftPhone1/lib/SoftPhone.rb:35:in `process_event'': Swig > director type mismatch in output value of type ''wxMenu *'' (TypeError) >I agree it''s not the most clear error message. What''s it telling you is that the method create_popup_menu is expected to return a value of type Wx::Menu, but you''re not doing this. In SWIG''s terminology, "director" methods are those, like create_popup_menu, where a ruby method is called on a certain event happening (in this case, right-clicking the icon) and you need to return a particular type (in this case, a Wx::Menu to be shown.> > (The rescue doesn''t catch the error). > > Here''s the code (it doesn''t matter which variant of the evt_menu call > I use): > > class SysTrayIcon < TaskBarIcon > > def initialize(parent) > > super() > > @softPhone = parent # soft_phone_frame > > icon = Icon.new("icons/phone.ico", BITMAP_TYPE_ICO) > > set_icon(icon, "Valcom VIP Page") > > end > > def create_popup_menu > > menu = Menu.new > > close_item = menu.append(101, ''Close VIP-Page'', ''Close VIP-Page'') > > evt_menu(close_item, :on_close) ># add this here, and delete the rescue clause return menu> > end > > def on_close(event) > > @softphone.exit > > end > > end >cheers alex _______________________________________________ wxruby-users mailing list wxruby-users at rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users