[dia] Maintain connection status of BezierConn for point change



commit 494f14f31efb9332bb5ea8c42e9cffc12edf4a98
Author: Hans Breuer <hans breuer org>
Date:   Sun Sep 4 20:58:22 2011 +0200

    Maintain connection status of BezierConn for point change
    
    Changing the all the "bez_points" including it's number were
    messing the connection state of e.g. 'Standard - BezierLine'.

 lib/bezier_conn.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/lib/bezier_conn.c b/lib/bezier_conn.c
index d41307c..86bd2e4 100644
--- a/lib/bezier_conn.c
+++ b/lib/bezier_conn.c
@@ -664,8 +664,17 @@ bezierconn_update_data(BezierConn *bez)
   
   /* handle the case of whole points array update (via set_prop) */
   if (3*bez->numpoints-2 != obj->num_handles) {
+    /* also maintain potential connections */
+    ConnectionPoint *cps = bez->object.handles[0]->connected_to;
+    ConnectionPoint *cpe = bez->object.handles[obj->num_handles-1]->connected_to;
+
     g_assert(0 == obj->num_connections);
 
+    if (cps)
+      object_unconnect (&bez->object, bez->object.handles[0]);
+    if (cpe)
+      object_unconnect (&bez->object, bez->object.handles[obj->num_handles-1]);
+
     for (i = 0; i < obj->num_handles; i++)
       g_free(obj->handles[i]);
     g_free(obj->handles);
@@ -674,6 +683,11 @@ bezierconn_update_data(BezierConn *bez)
     obj->handles = g_new(Handle*, obj->num_handles); 
 
     new_handles(bez, bez->numpoints);
+    /* we may assign NULL once more here */
+    if (cps)
+      object_connect(&bez->object, bez->object.handles[0], cps);
+    if (cpe)
+      object_connect(&bez->object, bez->object.handles[obj->num_handles-1], cpe);
   }
 
   /* Update handles: */



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