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 82257 - Clist snaps to end when in auto-search mode
Clist snaps to end when in auto-search mode
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: Other
1.2.x
Other All
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2002-05-19 12:59 UTC by Richard Eckart
Modified: 2011-02-04 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix problem with GtkRange that makes scrollbars snap to end. (1.23 KB, patch)
2002-05-20 16:51 UTC, Richard Eckart
none Details | Review

Description Richard Eckart 2002-05-19 12:59:28 UTC
There is roundding where none should be because of a missing cast from
(int) to (float). Patch:

diff -ru gtk+1.2-1.2.10/gtk/gtkrange.c gtk+1.2-1.2.10.fixed/gtk/gtkrange.c
--- gtk+1.2-1.2.10/gtk/gtkrange.c	Tue Feb 20 02:14:13 2001
+++ gtk+1.2-1.2.10.fixed/gtk/gtkrange.c	Sun May 19 14:43:20 2002
@@ -420,8 +420,8 @@
 	}
 
       if (range->adjustment->lower != (range->adjustment->upper -
range->adjustment->page_size))
-
x += ((right - left) * (range->adjustment->value - range->adjustment->lower) /
-
      (range->adjustment->upper - range->adjustment->lower -
range->adjustment->page_size));
+
x += ((float)(right - left) * (float)(range->adjustment->value -
range->adjustment->lower) /
+
      (float)(range->adjustment->upper - range->adjustment->lower -
range->adjustment->page_size));
 
       if (x < left)
 	x = left;
@@ -462,8 +462,8 @@
 	}
 
       if (range->adjustment->lower != (range->adjustment->upper -
range->adjustment->page_size))
-
y += ((bottom - top) * (range->adjustment->value - range->adjustment->lower) /
-
      (range->adjustment->upper - range->adjustment->lower -
range->adjustment->page_size));
+
y += ((float)(bottom - top) * (float)(range->adjustment->value -
range->adjustment->lower) /
+
      (float)(range->adjustment->upper - range->adjustment->lower -
range->adjustment->page_size));
 
       if (y < top)
 	y = top;
Comment 1 Owen Taylor 2002-05-20 15:57:28 UTC
I don't see the bug ... 

[int] * [float] promotes to float, not int.
Comment 2 Richard Eckart 2002-05-20 16:51:53 UTC
Created attachment 8603 [details] [review]
Fix problem with GtkRange that makes scrollbars snap to end.
Comment 3 Richard Eckart 2002-05-20 16:53:59 UTC
I'm afraid you're wrong. The scenario is this: I have a clist which
is in auto_sort_mode. If I insert something into the list it either
snaps to the start or to the end. When I added the (float) cast to
these lines, the problem was resolved. Either you're wrong what the
type promotion belongs, or it is a bug in gcc. Anyway... those casts
are really little work it insert and they resolve the problem.

Also see: 
http://www.geocrawler.com/archives/3/488/2001/2/0/5256537/
http://sourceforge.net/tracker/index.php?func=detail&aid=493905&group_id=4467&atid=104467
http://sourceforge.net/tracker/index.php?func=detail&aid=541803&group_id=4467&atid=104467

A testcase is at:
http://mail.gnome.org/archives/gtk-app-devel-list/1999-November/msg00205.html

I guy on IRC reported the same problem with an app he is developing.
This bug is _not_ resolved by just closing and ignoring it, sorry.

Richard
Comment 4 Owen Taylor 2002-05-20 17:12:40 UTC
Haven't had a chance to try out the test case yet, but:

$ md5sum gtkrange.lo 
0f8dab416debac9c5b799207f700042d  gtkrange.lo
gtk$ patch < /tmp/range.diff 
patching file gtkrange.c
gtk$ make gtkrange.lo
/bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I..
-DG_LOG_DOMAIN=\"Gtk\" -DGTK_DISABLE_COMPAT_H
-DGTK_LIBDIR=\"/usr/lib\" -DGTK_DATA_PREFIX=\"/usr\"
-DGTK_SYSCONFDIR=\"/etc\" -DGTK_LOCALEDIR=\"/usr/share/locale\" -I..
-DG_ENABLE_DEBUG -DUSE_XIM -I/usr/include/glib-1.2
-I/usr/lib/glib/include -D_REENTRANT -I/opt/xf/include    -g -O2 -g
-Wall -c gtkrange.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -DG_LOG_DOMAIN=\"Gtk\"
-DGTK_DISABLE_COMPAT_H -DGTK_LIBDIR=\"/usr/lib\"
-DGTK_DATA_PREFIX=\"/usr\" -DGTK_SYSCONFDIR=\"/etc\"
-DGTK_LOCALEDIR=\"/usr/share/locale\" -I.. -DG_ENABLE_DEBUG -DUSE_XIM
-I/usr/include/glib-1.2 -I/usr/lib/glib/include -D_REENTRANT
-I/opt/xf/include -g -O2 -g -Wall -Wp,-MD,.deps/gtkrange.pp -c
gtkrange.c  -fPIC -DPIC -o gtkrange.o
mv -f gtkrange.o gtkrange.lo
gtk$ md5sum gtkrange.lo 
0f8dab416debac9c5b799207f700042d  gtkrange.lo

Can you try doing the same thing? What version of GCC?
Comment 5 Richard Eckart 2002-05-20 18:34:56 UTC
You have a good point there. The fix really is invalid. Nevertheless
the test case _is_ valid and the "snap" bug is reproducable with it.
Please take a look at it and thanks very much for pointing out my
errors. I'll have to investigate further.

I changed to summary to reflect this.

Richard
Comment 6 Owen Taylor 2002-06-12 19:42:41 UTC
Don't expect to have time to look at this any time soon...
(clist is deprecated in current GTK+, so it isn't a high
priority.)
Comment 7 Owen Taylor 2004-02-24 00:53:05 UTC
No 1.2.11 is planned, so closing all 1.2.11 specific bugs.
Comment 8 Owen Taylor 2004-02-24 14:08:21 UTC
*Really* close all 1.2.11 bugs, instead of just adding a comment...