[cairo-commit] goocanvas/src goocanvaspolylineview.c,1.18,1.19

Damon Chaplin commit at pdx.freedesktop.org
Mon Sep 11 04:09:17 PDT 2006


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv5050/src

Modified Files:
	goocanvaspolylineview.c 
Log Message:
2006-09-11  Damon Chaplin  <damon at gnome.org>

	* src/goocanvaspolylineview.c: be more careful about using points and
	arrow data.

	* demo/demo.c (setup_lines): add checks for polylines with 0 and 1
	points.

	* configure.in: require GTK+ 2.10.0, for GtkUnit (Gian Mario
	Tagliaretti).



Index: goocanvaspolylineview.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvaspolylineview.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- goocanvaspolylineview.c	30 Aug 2006 12:18:48 -0000	1.18
+++ goocanvaspolylineview.c	11 Sep 2006 11:09:15 -0000	1.19
@@ -99,14 +99,17 @@
 
   cairo_new_path (cr);
 
+  if (polyline->num_points == 0)
+    return;
+
   /* If there is an arrow at the start of the polyline, we need to move the
      start of the line slightly to avoid drawing over the arrow tip. */
-  if (polyline->start_arrow)
+  if (polyline->start_arrow && polyline->num_points >= 2)
     cairo_move_to (cr, arrow->line_start[0], arrow->line_start[1]);
   else
     cairo_move_to (cr, polyline->coords[0], polyline->coords[1]);
 
-  if (polyline->end_arrow)
+  if (polyline->end_arrow && polyline->num_points >= 2)
     {
       gint last_point = polyline->num_points - 1;
 
@@ -140,6 +143,9 @@
 
   cairo_new_path (cr);
 
+  if (polyline->num_points < 2)
+    return;
+
   cairo_move_to (cr, arrow->start_arrow_coords[0],
 		 arrow->start_arrow_coords[1]);
   for (i = 1; i < NUM_ARROW_POINTS; i++)
@@ -160,6 +166,9 @@
 
   cairo_new_path (cr);
 
+  if (polyline->num_points < 2)
+    return;
+
   cairo_move_to (cr, arrow->end_arrow_coords[0],
 		 arrow->end_arrow_coords[1]);
   for (i = 1; i < NUM_ARROW_POINTS; i++)
@@ -234,6 +243,7 @@
 
   /* Check the arrows, if the polyline has them. */
   if (!found_view && (polyline->start_arrow || polyline->end_arrow)
+      && polyline->num_points >= 2
       && (pointer_events & GOO_CANVAS_EVENTS_STROKE_MASK)
       && (!(pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK) || do_stroke))
     {
@@ -271,11 +281,18 @@
   GooCanvasItemSimple *simple = GOO_CANVAS_ITEM_SIMPLE (polyline);
   GooCanvasBounds tmp_bounds;
 
+  if (polyline->num_points == 0)
+    {
+      bounds->x1 = bounds->x2 = bounds->y1 = bounds->y2 = 0.0;
+      return;
+    }
+
   goo_canvas_polyline_view_create_path (polyline, cr);
   goo_canvas_item_simple_get_path_bounds (simple, cr, bounds);
 
   /* Add on the arrows, if required. */
-  if (polyline->start_arrow || polyline->end_arrow)
+  if ((polyline->start_arrow || polyline->end_arrow)
+      && polyline->num_points >= 2)
     {
       /* We use the stroke pattern to match the style of the line. */
       goo_canvas_item_simple_set_stroke_options (simple, cr);
@@ -396,7 +413,8 @@
   goo_canvas_item_simple_paint_path (simple, cr);
 
   /* Paint the arrows, if required. */
-  if (polyline->start_arrow || polyline->end_arrow)
+  if ((polyline->start_arrow || polyline->end_arrow)
+      && polyline->num_points >= 2)
     {
       /* We use the stroke pattern to match the style of the line. */
       goo_canvas_item_simple_set_stroke_options (simple, cr);



More information about the cairo-commit mailing list