Re: [gtkmm] Segfault on spin button initialisation
- From: Carl Nygard <cjnygard fast net>
- To: Richard Shaw <look_in_sig sig com>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] Segfault on spin button initialisation
- Date: Tue, 20 Jul 2004 22:32:07 -0400
On Tue, 2004-07-20 at 06:02, Richard Shaw wrote:
> I've got a set up like this at the moment:
>
> ==Header==
> class GtkImageOutput : public Gtk::Window {
> public:
> GtkImageOutput();
> protected:
> Gtk::Adjustment adj;
> Gtk::SpinButton zoom;
> }
>
> ==Source==
> GtkImageOutput::GtkImageOutput() :
> adj(1.0, 1.0, 4.0, 1.0, 2.0, 1.0),
> zoom(adj)
> {
> ..
> }
>
> This set up is fine and compiles, however if I have the declarations for adj
> and zoom in the opposite order, I get a segfault, stemming from
> "Gtk::SpinButton::SpinButton () from /usr/lib/libgtkmm-2.4.so.1". I can only
> presume that the initializations are getting reordered, and so when zoom(adj)
> is called, adj is still uninitialised. If so, is the correct behaviour from
> the compiler? It just seemed a little strange. I'm using gcc 3.3.4.
Compiler is correct. C++ Standard (see Stroustrop) specifies that order
of member initialization follows order of declaration in the class,
regardless of the order you specify the initializers in your ctor.
The solution is proper ordering of dependent member data.
Regards,
Carl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]