Re: where is error?



Murray Cumming wrote:
> It should of course be
> 
> Glib::RefPtr<Radio_action> Radio_action::create(RadioActionGroup& group)
> {
>   return Glib::RefPtr<Radio_action>( new Radio_action(group) );
> }
> 
> Again, I have no idea whether this will stop your segfault.

It will not, since it uses the same constructor, only with RefPtr wrapped
over the constructed object.  I actually _checked_ this and experienced
the same crash, as expected.

Can anyone check if this happens with recent Gtkmm too?  Can anyone
understand (and fix) the reason of the crash?

(I might have not been nice, but it's not like I asked the list when I
first saw the crash.  I encountered it in a real program, pondered for a
while and created small test below.  I'm pretty sure it's a problem/bug of
Gtkmm, but cannot check with recent versions.)

Paul


#include <glibmm/refptr.h>
#include <gtkmm/main.h>
#include <gtkmm/radioaction.h>
#include <gtkmm/stock.h>


namespace
{

  class Radio_action : public Gtk::RadioAction
  {
  public:

    Radio_action (Group& group)
      : Gtk::RadioAction (group, "test", Gtk::StockID (), "", "")
    { }

    static  Glib::RefPtr <Radio_action>
    create (Group& group)
    {
      return Glib::RefPtr <Radio_action> (new Radio_action (group));
    }
  };

}


int
main (int argc, char** argv)
{
  Gtk::Main  main (argc, argv);

  Radio_action::Group  test_group;

#if 1
  // This segfaults.
  Radio_action::create (test_group);
#else
  Gtk::RadioAction::create (test_group, "test");
#endif

  return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]