Re: [gtkmm] adding a widget to a container



Hi again,

I'm not quite sure I follow your description, but there are a couple of
things I can point at for you to investigate further:

On Mon, May 03, 2004 at 06:00:26PM +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;

If you declare a static, it's visible only to that translation unit
(think of this as the .cc file and all the files it #includes). Putting
a static in a .h file is almost always the wrong thing to do - if two
.cc files include it, you end up with TWO copies of the variable, both
with the same name, but not the same variable. If you're including
Plugin.hh from two different .cc files, and setting the variable in one,
but using it in the other, you're not setting the same variable.

(General hint: Always initialise pointers at declaration. If you can't
give them their final value yet, initialise them to 0. If you do that
here, you can at least verify whether what I've described above is
what's happening in your code, by checking if it's still 0 before you
use it.)
 
> when i put this, it provoques a segfault: "in test : undefined symbol 
> toolbarmod"...

Do you mean a segfault here? or a link error?

~Ainsley.



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