GNOME Bugzilla – Bug 82257
Clist snaps to end when in auto-search mode
Last modified: 2011-02-04 16:09:06 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;
I don't see the bug ... [int] * [float] promotes to float, not int.
Created attachment 8603 [details] [review] Fix problem with GtkRange that makes scrollbars snap to end.
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
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?
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
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.)
No 1.2.11 is planned, so closing all 1.2.11 specific bugs.
*Really* close all 1.2.11 bugs, instead of just adding a comment...