GNOME Bugzilla – Bug 369335
Gtk::Adjustment ignores initial value in constructor
Last modified: 2006-12-14 21:50:17 UTC
Forwarded from: https://launchpad.net/distros/ubuntu/+source/gtkmm2.4/+bug/69806 Gtk::Adjustment seems to ignore the initial value it is given in its constructor. In the attached example, 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. See attached sources files. http://librarian.launchpad.net/4945898/main.cpp http://librarian.launchpad.net/4945899/Makefile On a brief glance: Code in gtkmm 2.8.5: Adjustment::Adjustment(double value, double lower, double upper, double step_increment, double page_increment, double page_size) : Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations. Gtk::Object(Glib::ConstructParams(adjustment_class_.init(), (char*) 0)) { gobj()->lower = lower; gobj()->upper = upper; gobj()->step_increment = step_increment; gobj()->page_increment = page_increment; gobj()->page_size = page_size; changed(); set_value(value); } void Adjustment::set_value(double value) { gtk_adjustment_set_value(gobj(), value); } (For some reason set_value() doesn't use gobj()->value = value; changed(); as the other set_*() do. But maybe that's a red herring.) ---- Code in gtkmm 2.10.2: Adjustment::Adjustment(double value, double lower, double upper, double step_increment, double page_increment, double page_si ze) : Glib::ObjectBase(0), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations. Gtk::Object(Glib::ConstructParams(adjustment_class_.init(), "value", value, "lower", lower, "upper", upper, "step_increment ", step_increment, "page_increment", page_increment, "page_size", page_size, (char*) 0)) { }
Created attachment 76192 [details] [review] adjustment_value.patch Suggested fix: 2006-11-08 Murray Cumming <murrayc@murrayc.com> * gtk/src/adjustment.ccg: * gtk/src/adjustment.hg: Hand-code the constructor so that we can provide the g_object_new() properties in a non-standard order, so that the value is not ignored. This is what gtk_adjustment_new() does too. Bug #369335 from Daniel Holbach, via Vincent Levesque in the Ubuntu Launchpad bug-tracker.
Paul Davis says on the mailing list that it fixes the problem. Committed to CVS.
*** Bug 385858 has been marked as a duplicate of this bug. ***