Re: [gtkmm] gtkmm segfaulting with g++ 3.3 and Gtk::Notebook



On Wednesday 27 August 2003 12:01 am, Chris Vine wrote:
>
> There is a bug in your program - you should either have the Gtk::Label
> object as a member, or allocate it using new().  As you had coded it, the
> label goes out of scope and therefore ceases to exist once the constructor
> is finished. (You also never realised it by calling show_all().)
>
> Doing that and making a call to show_all() makes it work correctly with
> g++-3.3.1.  (Actually, although as you had coded it, it didn't crash with
> g++3.2, it still didn't show the label and thus the notebook page even with
> a call to show_all(), because as soon as it is realised it ceases to
> exist).
>
> That doesn't actually explain why it crashed with your code with O2
> optimisation, because when you call
> Gtk::Notebook_Helpers::Page::get_child() the label does exist.  But perhaps
> that is a result of sensible but aggressive optimisation rather than a bug
> with g++.  The backtrace showed an absurd address (this=0x1) for
> Notebook_Helpers::Page.

Actually, on further trial I find it works with the Gtk::Label object as a 
member, but not when allocated with new().  That is obviously not correct, so 
maybe there is a bug with optimisation in g++ 3.3 after all (although the 
problem occurs with -O as well as -O2 optimisation).  I will have another 
look when I am not so tired.  There may be some other simple explanation.

Chris.




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