Comment 0 for bug 69806

Revision history for this message
Vincent Levesque (vleves) wrote :

Binary package hint: libgtkmm-2.4-dev

Gtk::Adjustment seems to ignore the initial value it is given in its constructor. In the example shown below, an adjustment is initialized to 1 and used with a SpinButton. When you run it though, the SpinButton has a value of 0 and get_value() returns 0. Using set_value() in the Window's constructor, on the other hand, correctly sets the initial value.

I was able to reproduce this bug on two computers running Ubuntu 6.10 but not on another one running Ubuntu 6.06. Using older versions of GCC doesn't seem to help.

Compile with: gcc -o test main.cpp `pkg-config gtkmm-2.4 --cflags` `pkg-config gtkmm-2.4 --libs`

main.cpp:
-------------

#include <gtkmm.h>

class MyWindow : public Gtk::Window
{
public:
 MyWindow() :
  adj(1,0,100), // initial value is ignored here
  spin(adj)
 {
  printf("%f\n", adj.get_value());
  //adj.set_value(1); // but accepted here
  set_size_request(300,100);
  add(spin);
  show_all_children();
 }

 Gtk::Adjustment adj;
 Gtk::SpinButton spin;
};

int main(int argc, char *argv[])
{
 Gtk::Main kit(argc, argv);
 MyWindow wnd;
 Gtk::Main::run(wnd);
 return 0;
}