Howdy, I''ve uncovered a bug in the constructor for TextCtrl (originally uncovered while using WxSugar but it appears to apply to WxRuby itself as well). Here''s the output from irb: # ------ irb(main):001:0> require ''wx''; irb(main):002:0* ctl Wx::TextCtrl.new(nil,-1,"",Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,0,Wx::DEFAULT_VALIDATOR,"my_name") => #<Wx::TextCtrl:0x2e7a188> irb(main):003:0> puts ctl.get_name => nil # That should have printed "my_name" # ----- It''s not a show-stopper, though, as you can just assign to ctl.name. This bug shows up when you are trying to do <Wx::Window>.find_window_by_name() and searching for a specific control Cheers -- -Phil <><
Hi> I''ve uncovered a bug in the constructor for TextCtrl (originally > uncovered while using WxSugar but it appears to apply to WxRuby itself > as well).Thanks for the report ...> # ------ > irb(main):001:0> require ''wx''; > irb(main):002:0* ctl > Wx::TextCtrl.new(nil,-1,"",Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,0,Wx::DEFAULT_VALIDATOR,"my_name") > => #<Wx::TextCtrl:0x2e7a188> > irb(main):003:0> puts ctl.get_name > > => nil > # That should have printed "my_name" > # ----- >There''s two things that are a bit unusual about the example. It''s creating a Window without an App being created (i.e. outside an on_init loop); this won''t work at all on OS X. Also any control should have a valid Window (frame, panel etc) as a parent, but this has nil as the first arg. If I use nil, then get_name returns "", but if I replace the ''nil'' with a frame, then the name is set properly. So basically I don''t think you want to create a TextCtrl without a proper parent - let me know if that doesnt'' resolve it. Probably we should amend the API so that both these situations trigger an exception rather than segfaults or strange behaviour. It''s easier to do this in WxSugar, but my hunch is it should be in core - what does anyone else think? alex
Howdy, That example was just supposed to be a smallest case - it exhibits the same behaviour while using the `add` method in Wx::Sugar: # in arrange_grid() in on_init() in a Wx::Frame add ( Wx::TextCtrl[ :name => "some name" ] ) do |textctrl| puts textctrl.name # Will return an empty string end # carry on in in_init() I''m assuming this may be due to the deferred constructor? (or is the a control create in this way not assigned an explicit parent? In that case, the example for Wx::Sugar should be amended) On 3/21/07, Alex Fenton <alex at pressure.to> wrote:> Hi > > I''ve uncovered a bug in the constructor for TextCtrl (originally > > uncovered while using WxSugar but it appears to apply to WxRuby itself > > as well). > Thanks for the report ... > > # ------ > > irb(main):001:0> require ''wx''; > > irb(main):002:0* ctl > > Wx::TextCtrl.new(nil,-1,"",Wx::DEFAULT_POSITION,Wx::DEFAULT_SIZE,0,Wx::DEFAULT_VALIDATOR,"my_name") > > => #<Wx::TextCtrl:0x2e7a188> > > irb(main):003:0> puts ctl.get_name > > > > => nil > > # That should have printed "my_name" > > # ----- > > > There''s two things that are a bit unusual about the example. It''s > creating a Window without an App being created (i.e. outside an on_init > loop); this won''t work at all on OS X. > > Also any control should have a valid Window (frame, panel etc) as a > parent, but this has nil as the first arg. If I use nil, then get_name > returns "", but if I replace the ''nil'' with a frame, then the name is > set properly. > > So basically I don''t think you want to create a TextCtrl without a > proper parent - let me know if that doesnt'' resolve it. > > Probably we should amend the API so that both these situations trigger > an exception rather than segfaults or strange behaviour. It''s easier to > do this in WxSugar, but my hunch is it should be in core - what does > anyone else think? > > alex > > > > > _______________________________________________ > Wxruby-development mailing list > Wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development >-- -Phil <><
Philip Schalm wrote:> Howdy, > > That example was just supposed to be a smallest case - it exhibits the > same behaviour while using the `add` method in Wx::Sugar: >Sorry for the trouble, Philip, I should have thought of this before - it''s a bug in the current release of WxSugar that''s fixed in SVN. I couldn''t release the fix until the new version of WxRuby2 was out that included the DEFAULT_VALIDATOR constant. I''ll put out WxSugar 0.1.14 shortly which should resolve things I hope. cheers alex
Howdy Alex, I just updated the gem, commented out my line manually setting the name, and everything works great. Thanks! On 3/22/07, Alex Fenton <alex at pressure.to> wrote:> Philip Schalm wrote: > > Howdy, > > > > That example was just supposed to be a smallest case - it exhibits the > > same behaviour while using the `add` method in Wx::Sugar: > > > > Sorry for the trouble, Philip, I should have thought of this before - > it''s a bug in the current release of WxSugar that''s fixed in SVN. I > couldn''t release the fix until the new version of WxRuby2 was out that > included the DEFAULT_VALIDATOR constant. > > I''ll put out WxSugar 0.1.14 shortly which should resolve things I hope. > > cheers > alex > > > _______________________________________________ > Wxruby-development mailing list > Wxruby-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-development >-- -Phil <><