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 478889 - GtkSpinButton does weird things while setting range.
GtkSpinButton does weird things while setting range.
Status: RESOLVED DUPLICATE of bug 307963
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-09-21 09:39 UTC by AWacha
Modified: 2008-05-19 00:37 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description AWacha 2007-09-21 09:39:46 UTC
Please describe the problem:
I am writing a program and want to use the spinbutton widget. I found something fishy about it: with gtk+ <=2.8 everything worked, but with 2.10 it does not. My problem is that if I set the range or the value of a spinbutton widget, sometimes it overwrites other variables. I suspect that somewhere inside libgtk2 some memory management errors could be present, because another version of the program (which uses gtkmm) fails too, with exactly these widgets. I use libglade and libglademm, respectively. I have chopped down my program to a working minimum, you can find it on the internet (see steps).

Steps to reproduce:
1. Download the source from: http://awacha.fw.hu
2. Untar it and build it (a simple make would suffice)
3. Run it ("./findcenter") and type 07779 in the field between ORG and .DAT on the window
4. Push OK.
5. Click mouse on the picture which appeared


Actual results:
In step 4. the program opens ORG07779.DAT which is present in the source directory and draws a picture (in fact, it is a Small Angle X-Ray Scattering picture, but never mind). It uses a gdk_pixbuf for the drawing. The color of a pixel is determined by where the actual count number (how many photons hit the detector at that pixel) lies between the min and max numbers (see bottom right of the window). If you click on the picture, recalcmaxcnt() runs (see findcenter.c) and the maximal value for max (ie. the greatest count number of the scattering pattern) is recalculated and the spinbuttons are set appropriately. But when gtk_spin_button_set_range runs, it overwrites the global variable maxcnt in the program, somehow. This can be seen on stderr, and on the picture too, because the colouring changes, although it should not.

Expected results:
Nothing visible should happen at all, when you click on the picture.

Does this happen every time?
Yes.

Other information:
Comment 1 Chris Wilson 2007-09-21 17:10:05 UTC
When adjusting the range on the spin button, the current value is clamped between the new lower and the new upper minus the page size - which is the oddity as the value need only be clamped to be within the new range. [This generates the callback whereby you overwrite the value of maxcnt with 0 - check the scope of your variables. You also have an off-by-one in the reflection of your y-coords, see adatkoord.]


Index: gtk/gtkspinbutton.c
===================================================================
--- gtk/gtkspinbutton.c (revision 18847)
+++ gtk/gtkspinbutton.c (working copy)
@@ -1831,7 +1831,7 @@ gtk_spin_button_set_range (GtkSpinButton
 
   value = CLAMP (spin_button->adjustment->value,
                  spin_button->adjustment->lower,
-                 (spin_button->adjustment->upper - spin_button->adjustment->page_size));
+                 spin_button->adjustment->upper);
 
   if (value != spin_button->adjustment->value)
     gtk_spin_button_set_value (spin_button, value);
Comment 2 Björn Lindqvist 2008-05-19 00:37:45 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.


*** This bug has been marked as a duplicate of 307963 ***