On Mon, Nov 09, 2009 at 10:44:38PM -0600, Udi Fuchs wrote:
> On Mon, Nov 9, 2009 at 7:18 AM, Frank van Maarseveen
> <fran...@frankvm.com> wrote:
> > Without this patch, nothing happens when pressing the zoom-out button
> > at exactly 200, 300 or 400%. I've adapted the zoom-in code similarly
> > to maintain symmetry. But as integrals below a very large number are
> > exactly representable in floating point it is only the zoom-out code
> > which actually needs the 0.001 tweak.
> 
> I'm not sure what the bug is. The only way I can reproduce it is by
> typing something like 300.1 into the zoom entry. Then it show like 300
> and zoom-out give 300, but the next zoom-out is fine.

Here it still doesn't except when I add printf("%a") to see where it
goes wrong: it is a heisenbug :-(. Trying it out in a test program didn't
work either. So, it's probably a compiler/glibc issue here.

Look at the code assuming zoom is exactly 300%:

    if (zoom > 100.0) {
        zoom = (ceil(zoom / 100.0) - 1) * 100.0;

If there is even the tiniest (rounding) error somewhere then ceil doesn't
see 300.0/100.0=3.0 but 3.00000000000000000000000001 and the result will
be 300% again.

It could be argued that since the zoom control doesn't show digits after
the decimal point (it should round them), the correct code should be
something that rounds too, like in attached patch.

-- 
Frank
diff --git a/ufraw_preview.c b/ufraw_preview.c
index 7421ae8..df5ca68 100644
--- a/ufraw_preview.c
+++ b/ufraw_preview.c
@@ -2020,6 +2020,7 @@ static void zoom_in_event(GtkWidget *widget, gpointer 
user_data)
 
     double zoom = CFG->Zoom;
     if (zoom >= 100.0) {
+       zoom += 0.5;
        zoom = (floor(zoom/100.0) + 1) * 100.0;
     } else {
        int scale = zoom_to_scale(zoom);
@@ -2042,6 +2043,7 @@ static void zoom_out_event(GtkWidget *widget, gpointer 
user_data)
 
     double zoom = CFG->Zoom;
     if (zoom > 100.0) {
+       zoom -= 0.5;
        zoom = (ceil(zoom / 100.0) - 1) * 100.0;
     } else {
        int scale = zoom_to_scale(zoom);
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
ufraw-devel mailing list
ufraw-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ufraw-devel

Reply via email to