[gtkmm] adding a widget to a container



Hello,
i m sorry to ask for help again and again, but i ve a PARANORMAL (yes...) error!!!

in one of my class constructors, i ve created a toolbar which i want to add to a Gtk::HBox.
the toolbar is declared as "Gtk::Toolbar toolbarmod;" in my testmodule.hh.

in the constructor of testmodule.cc:

...

Gtk::HBox a;    a.add(toolbarmod);
//it works, normal

Gtk::HBox *b;    b->add(toolbarmod);
// provoques a seg fault !?!?!

Gtk::HBox *c;    (*c).add(toolbarmod);
// provoques a seg fault !?!?!

...

i ve no compilation error with both of these instructions!
but when i execute them, it s ok with the first one, but i have a segfault (symbol toolbarmod undefined) with the second and the third ones. it don t underdstand: it should work with none or all of them, but not just some of them since it s the same thing! i ve put some cout<< fooX <<endl before and after these instructions, so i m sure that it s the instruction itself which provoques the seg fault, so it s not because of the temporary a,b,c variables which are deleted. initially i worked with a global ptr instead of a,b,c.

if you have any explanation, i really would like you to tell me! ;-)
grateful thanks!

cedric



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