[dia] Bug 554659 - validate "Standard - Arc" constraints also on load



commit 654f4ea3aafe304c569114f43bc809586d5638a5
Author: Hans Breuer <hans breuer org>
Date:   Tue Jun 14 17:35:40 2011 +0200

    Bug 554659 - validate "Standard - Arc" constraints also on load
    
    The one thing wrong in the diagram causing bug 554659 was an arc
    reduced to a single point with curve_distance=nan. Now these can't
    happen anymore from the UI, validating also on load should make
    the diagram work completely again.

 objects/standard/arc.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/objects/standard/arc.c b/objects/standard/arc.c
index 6c43773..81e194b 100644
--- a/objects/standard/arc.c
+++ b/objects/standard/arc.c
@@ -718,7 +718,10 @@ arc_update_data(Arc *arc)
   y2 = endpoints[1].y;
   
   lensq = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
-  radius = lensq/(8*arc->curve_distance) + arc->curve_distance/2.0;
+  if (arc->curve_distance > 0.01)
+    radius = lensq/(8*arc->curve_distance) + arc->curve_distance/2.0;
+  else
+    radius = 0.0; /* not really but used for bbox calculation below */
 
   if (lensq == 0.0 || arc_is_line (arc))
     alpha = 1.0; /* arbitrary, but /not/ 1/0  */
@@ -934,6 +937,17 @@ arc_load(ObjectNode obj_node, int version, const char *filename)
   arc->middle_handle.connect_type = HANDLE_NONCONNECTABLE;
   arc->middle_handle.connected_to = NULL;
 
+  /* older versions did not prohibit everything reduced to a single point
+   * and afterwards failed on all the calculations producing nan.
+   */
+  if (distance_point_point (&arc->connection.endpoints[0], 
+                            &arc->connection.endpoints[1]) < 0.02) {
+    arc->curve_distance = 0.0;
+    arc->connection.endpoints[0].x -= 0.01;
+    arc->connection.endpoints[1].x += 0.01;
+    arc_update_handles (arc);
+  }
+
   arc_update_data(arc);
 
   return &arc->connection.object;



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