goocanvas r37 - in trunk: . src



Author: damon
Date: Mon Dec 29 20:30:09 2008
New Revision: 37
URL: http://svn.gnome.org/viewvc/goocanvas?rev=37&view=rev

Log:

2008-12-29  Damon Chaplin  <damon gnome org>

	    * src/goocanvasgrid.c (calculate_start_position)
	    (paint_vertical_lines, paint_horizontal_lines): handle step <= 0.0.
	    It should now draw a single line at the start position.
	    (based on patch from Murray Cumming) #563487.



Modified:
   trunk/ChangeLog
   trunk/src/goocanvasgrid.c

Modified: trunk/src/goocanvasgrid.c
==============================================================================
--- trunk/src/goocanvasgrid.c	(original)
+++ trunk/src/goocanvasgrid.c	Mon Dec 29 20:30:09 2008
@@ -664,15 +664,16 @@
 			  gdouble redraw_start_pos,
 			  gdouble line_width)
 {
-  gdouble n, result;
+  gdouble n = 0.0, result;
 
   /* We want the first position where pos + line_width/2 >= redraw_start_pos.
      i.e. start_pos + (n * step) + (line_width / 2) >= redraw_start_pos,
      or   (n * step) >= redraw_start_pos - start_pos - (line_width / 2),
      or   n >= (redraw_start_pos - start_pos - (line_width / 2) / step). */
-  n = ceil (((redraw_start_pos - start_pos - (line_width / 2.0))) / step);
+  if (step > 0.0)
+    n = ceil (((redraw_start_pos - start_pos - (line_width / 2.0))) / step);
 
-  if (n <= 0)
+  if (n <= 0.0)
     result = start_pos;
   else
     result = start_pos + (n * step);
@@ -734,6 +735,10 @@
       cairo_line_to (cr, x, max_y);
       cairo_stroke (cr);
 
+      /* Avoid an infinite loop. */
+      if (grid_data->x_step <= 0.0)
+        break;
+
       x += grid_data->x_step;
     }
 }
@@ -792,6 +797,10 @@
       cairo_line_to (cr, max_x, y);
       cairo_stroke (cr);
 
+      /* Avoid an infinite loop. */
+      if (grid_data->y_step <= 0.0)
+        break;
+
       y += grid_data->y_step;
     }
 }



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