I've been following this thread a bit and I did some checking. I may be
way off base here but after doing some checking I think that RadioGroup
wasn't meant to be overridden.
RadioAction::RadioAction(Group& group, const Glib::ustring& name, const
Gtk::StockID& stock_id, const Glib::ustring& label, const Glib::ustring&
tooltip)
:
Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather
than a custom class, to allow vfunc optimisations.
I found this bit in the constructor in radioaction.cc line 35 of version
2.6.something
I have very little experience with the gtk/gnome underpinnings but this
was a red flag so I thought I'd mention it.
It is quite weird.
...
A thought occurred to me. I dunno why or how but this works:
The important part seems to be theL
Glib::ObjectBase(0)
Perhaps Murray can indulge us all. It seems like one of those C++
gotchyas from where I'm sitting. Granted thats post-alcohol, but still...
#include <gtkmm.h>
class Radio_action : public Gtk::RadioAction
{
public:
Radio_action (Gtk::RadioButtonGroup& group)
:
Glib::ObjectBase(0),
Gtk::RadioAction ()
{
set_group( group ) ;
}
static
Glib::RefPtr<Gtk::RadioAction> Radio_action::create(
Gtk::RadioButtonGroup& group)
{
return Glib::RefPtr<Radio_action>( new Radio_action(group) );
}
};
int
main (int argc, char** argv)
{
Gtk::Main main (argc, argv);
Gtk::RadioButtonGroup test_group;
#if 1
// This segfaults.
Radio_action::create (test_group);
#else
Gtk::RadioAction::create (test_group, "test");
#endif
return 0;
}
I sure could go into whether this is a library or a user thing. But I
have got to say, reading the source sure helps quite a bit.
Paul Pogonyshev wrote:
>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;
>}
>_______________________________________________
>gtkmm-list mailing list
>[email protected]
>http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
>
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list