Re: [gtkmm] adding a widget to a container



Ainsley Pereira a écrit :

On Tue, May 04, 2004 at 10:37:50AM +0200, cedric wrote:
so to do this, i ve 2 ptr declared in my Plugin.hh file
static Gtk::HBox *toolBarModContainer_ptr;
static Gtk::Toolbar *toolBarModDisplayed_ptr;

Do you mean within a class declaration? If so, you'll also need to
define them in a .cc file, without using the static keyword, eg:
// in fred.h
class fred
{
static Gtk::HBox* hbox;
};

// in fred.cc
Gtk::HBox* fred::hbox = 0; // and you can initialise it too

In this case there is only one variable, even if fred.h is included
multiple times. (Which is different to how it would be if the variable
were declared outside of a class definition, but there wasn't enough
context from your earlier mails for me to work out whether it was in a
class or not.)

yes you re, maybe i didn t tell clearly it was in a class :-[ sorry!
so i was right since the beginning!   :p

it s a seg fault, but there is a link error instead if declare toolbarmod as static.

Obviously with the above, you will still need something to set that
pointer to a sensible value before you use it.

i ve tried to attach the toolbars in the loadplugs.cc file and it works now!
but i still dont see why it was provoquing segfaults in the modules ?!?
because i m now sure that the pointers were always correctly used!

thanks,

cedric




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