After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 369335 - Gtk::Adjustment ignores initial value in constructor
Gtk::Adjustment ignores initial value in constructor
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.9.x
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
: 385858 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-11-02 10:21 UTC by Daniel Holbach
Modified: 2006-12-14 21:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adjustment_value.patch (2.68 KB, patch)
2006-11-08 01:56 UTC, Murray Cumming
none Details | Review

Description Daniel Holbach 2006-11-02 10:21:38 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))
{
  }
Comment 1 Murray Cumming 2006-11-08 01:56:24 UTC
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.
Comment 2 Murray Cumming 2006-11-08 22:04:19 UTC
Paul Davis says on the mailing list that it fixes the problem. Committed to CVS.
Comment 3 Murray Cumming 2006-12-14 21:50:17 UTC
*** Bug 385858 has been marked as a duplicate of this bug. ***