[genius] Tue Jun 25 14:48:55 2013 Jiri (George) Lebl <jirka 5z com>



commit 95359c5fdc805a1725f60825db2b7183d2179b6d
Author: Jiri (George) Lebl <jirka 5z com>
Date:   Tue Jun 25 14:56:28 2013 -0500

    Tue Jun 25 14:48:55 2013  Jiri (George) Lebl <jirka 5z com>
    
        * gtkextra/gtkplot.c: fix a very nasty infinite loop with a memory leak
          on very very large zoom due to a numerical issue.

 ChangeLog          |    5 +++++
 NEWS               |    7 +++++--
 gtkextra/gtkplot.c |   18 ++++++++++++++----
 3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3939bb6..ced7ae3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun 25 14:48:55 2013  Jiri (George) Lebl <jirka 5z com>
+
+       * gtkextra/gtkplot.c: fix a very nasty infinite loop with a memory leak
+         on very very large zoom due to a numerical issue.
+
 Fri Jun 14 15:19:19 2013  Jiri (George) Lebl <jirka 5z com>
 
        * gtkextra/gtkplot3d.c: fix placement of labels.
diff --git a/NEWS b/NEWS
index 7c96933..9a58425 100644
--- a/NEWS
+++ b/NEWS
@@ -2,8 +2,8 @@ Changes to 1.0.17
 
 * Better precision for graphs especially when zoomed it a lot, and make font
   smaller if needed
-* Line plots and parametric plots now allow "fit dependent axis" automatically when
-  z limits are unspecified.  And this is the default in the UI
+* Line plots and parametric plots now allow "fit dependent axis" automatically
+  when y limits are unspecified.  And this is the default in the UI
 * Add export of graphs to PDF directly
 * Line plot step size is adaptive, also line plots now detect jumps and do not
   draw a connecting line, try plotting UnitStep for example
@@ -20,6 +20,9 @@ Changes to 1.0.17
 * A few small fixes and updates to the documentation
 * A few minor bugfixes
 * Update mersenne primes (new one is known)
+* Translation updates (Daniel Mustieles, Marek Černocký, Dimitris Spingos,
+  Jiro Matsuzawa, Kjartan Maraas, Martin Srebotnjak, Matej Urbančič,
+  Gil Forcada, Alexandre Franke, Joe Hansen, Miguel Rodríguez)
 
 * During making of these changes the author (Jiri) was partially supported by
   NSF grant DMS 0900885 and the University of Wisconsin-Madison
diff --git a/gtkextra/gtkplot.c b/gtkextra/gtkplot.c
index 3a2264a..6c776c5 100644
--- a/gtkextra/gtkplot.c
+++ b/gtkextra/gtkplot.c
@@ -4708,6 +4708,8 @@ gtk_plot_ticks_autoscale(GtkPlotAxis *axis, gdouble xmin, gdouble xmax, gint *pr
           xmax = floor(xmax/pow(10., pmax)) * pow(10., pmax);
           pstep = floor(log10(fabs(dx)));
           dx = ticks->step = floor(dx/pow(10., pstep)) * pow(10., pstep);
+         /* FIXME: this could lead to numerical trouble and infinite
+          * loop if dx is too small compared to xmin or xmax */
           while(xmin >= amin) xmin -= dx;
           while(xmax <= amax) xmax += dx;
           dx = floor((xmax - xmin)/ticks->step);
@@ -6600,15 +6602,18 @@ printf("%f %f\n",max/ticks->step,ceil(max/ticks->step));
         major[nmajor-1].value = tick;
         major[nmajor-1].minor = FALSE;
      }
+     n++;
      switch(scale){
         case GTK_PLOT_SCALE_LINEAR:
-            tick += major_step; 
+            tick = min + n * major_step; 
             break;
         case GTK_PLOT_SCALE_LOG10:
-            n++;
             tick = tick_step * pow(10., n*major_step); 
             break;
      }
+     /* FIXME: hard bailout limit in case something is totally off
+      * to avoid locking up */
+     if (nmajor > 1000) { printf("EEEEEEEEEEEEEEK!\n"); break;}
    }
   }
 
@@ -6646,10 +6651,15 @@ printf("%f %f\n",max/ticks->step,ceil(max/ticks->step));
     for(i = 0; i < ticks->nminor; i++){
      switch(scale){
         case GTK_PLOT_SCALE_LINEAR:
-            tick += minor_step; 
+            /* we really do this but in a numerically safer way:
+            tick += minor_step; */
+            tick = tick_step + i * minor_step;
             break;
         case GTK_PLOT_SCALE_LOG10:
-            tick += tick_step; 
+           /* FIXME: is this correct? this seems wrong */
+            /* we really do this but in a numerically safer way:
+            * tick += tick_step; */
+            tick = tick_step + i * tick_step;
             break;
      }   
      if(tick >= absmin-major_step*1.E-2 && tick <= absmax+major_step*1.E-2){


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]