[dia] [cleanup] Get rid of ConnectionPoint::last_pos



commit 99c2ccd5a0e032a73727cfe8d5042ef15c79b841
Author: Hans Breuer <hans breuer org>
Date:   Thu Jan 2 11:30:06 2014 +0100

    [cleanup] Get rid of ConnectionPoint::last_pos
    
    Makes sizeof(ConnectionPoint)==32, before it was 48.
    The single real user diagram_update_connections_object() was easy
    to convert with other 'redundant' position information. So one less
    extra field to maintain.

 app/connectionpoint_ops.c      |   20 +++++++++++---------
 app/load_save.c                |    4 +---
 lib/connectionpoint.h          |    1 -
 objects/Database/table.c       |    1 -
 objects/ER/attribute.c         |    1 -
 objects/ER/entity.c            |    1 -
 objects/ER/relationship.c      |    1 -
 objects/FS/function.c          |    1 -
 objects/Misc/measure.c         |   16 ++++++++--------
 objects/UML/class.c            |    1 -
 objects/custom/custom_object.c |    1 -
 objects/standard/box.c         |    4 +---
 objects/standard/ellipse.c     |    1 -
 objects/standard/image.c       |    1 -
 14 files changed, 21 insertions(+), 33 deletions(-)
---
diff --git a/app/connectionpoint_ops.c b/app/connectionpoint_ops.c
index f11dc7c..ac4b9e4 100644
--- a/app/connectionpoint_ops.c
+++ b/app/connectionpoint_ops.c
@@ -139,26 +139,28 @@ diagram_update_connections_object(Diagram *dia, DiaObject *obj,
 
   for (i=0;i<dia_object_get_num_connections(obj);i++) {
     ConnectionPoint *cp = obj->connections[i];
-    if ((update_nonmoved) ||
-       (distance_point_point_manhattan(&cp->pos, &cp->last_pos) > CHANGED_TRESHOLD)) {
-      cp->last_pos = cp->pos;
-
+    if (cp->connected) {
       list = cp->connected;
       while (list!=NULL) {
+       gboolean any_move = FALSE;
        DiaObject *connected_obj = (DiaObject *) list->data;
 
        object_add_updates(connected_obj, dia);
        for (j=0;j<connected_obj->num_handles;j++) {
          if (connected_obj->handles[j]->connected_to == cp) {
            Handle *handle = connected_obj->handles[j];
-           connected_obj->ops->move_handle(connected_obj, handle, &cp->pos,
-                                           cp, HANDLE_MOVE_CONNECTED,0);
+           if (distance_point_point_manhattan(&cp->pos, &handle->pos) > CHANGED_TRESHOLD) {
+             connected_obj->ops->move_handle(connected_obj, handle, &cp->pos,
+                                             cp, HANDLE_MOVE_CONNECTED,0);
+             any_move = TRUE;
+           }
          }
        }
-       object_add_updates(connected_obj, dia);
+       if (update_nonmoved || any_move) {
+         object_add_updates(connected_obj, dia);
 
-       diagram_update_connections_object(dia, connected_obj, FALSE);
-       
+         diagram_update_connections_object(dia, connected_obj, FALSE);
+       }       
        list = g_list_next(list);
       }
     }
diff --git a/app/load_save.c b/app/load_save.c
index 70fa280..2b55e07 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -277,8 +277,6 @@ read_connections(GList *objects, xmlNodePtr layer_node,
                             to->connections[conn]);
              /* force an update on the connection, helpful with (incomplete) generated files */
              if (wants_update) {
-               obj->handles[handle]->pos = 
-                 to->connections[conn]->last_pos = to->connections[conn]->pos;
 #if 0
                obj->ops->move_handle(obj, obj->handles[handle], &to->connections[conn]->pos,
                                      to->connections[conn], HANDLE_MOVE_CONNECTED,0);
@@ -1202,7 +1200,7 @@ diagram_autosave(Diagram *dia)
       if (dia->autosavefilename != NULL) 
        g_free(dia->autosavefilename);
       dia->autosavefilename = save_filename;
-#ifdef AUTOSAVE_IN_THREAD /* G_THREADS_ENABLED */
+#if 0 //def G_THREADS_ENABLED
       if (g_thread_supported ()) {
         AutoSaveInfo *asi = g_new (AutoSaveInfo, 1);
         GError *error = NULL;
diff --git a/lib/connectionpoint.h b/lib/connectionpoint.h
index 2153800..48aec49 100644
--- a/lib/connectionpoint.h
+++ b/lib/connectionpoint.h
@@ -72,7 +72,6 @@ typedef enum {
  */
 struct _ConnectionPoint {
   Point pos;         /*!< position of this connection point */
-  Point last_pos;    /*!< Used by update_connections_xxx only. */
   DiaObject *object; /*!< pointer to the object having this point */
   GList *connected;  /*!< list of 'DiaObject *' connected to this point*/
   guint8 directions; /*!< Directions that this connection point is open to */
diff --git a/objects/Database/table.c b/objects/Database/table.c
index d4c7998..21e508a 100644
--- a/objects/Database/table.c
+++ b/objects/Database/table.c
@@ -817,7 +817,6 @@ table_copy(Table * orig)
       copy->connections[i].object = copy_obj;
       copy->connections[i].connected = NULL;
       copy->connections[i].pos = orig->connections[i].pos;
-      copy->connections[i].last_pos = orig->connections[i].last_pos;
     }
 
   copy->name = g_strdup (orig->name);
diff --git a/objects/ER/attribute.c b/objects/ER/attribute.c
index 330e314..a568106 100644
--- a/objects/ER/attribute.c
+++ b/objects/ER/attribute.c
@@ -479,7 +479,6 @@ attribute_copy(Attribute *attribute)
     newattribute->connections[i].object = newobj;
     newattribute->connections[i].connected = NULL;
     newattribute->connections[i].pos = attribute->connections[i].pos;
-    newattribute->connections[i].last_pos = attribute->connections[i].last_pos;
     newattribute->connections[i].flags = attribute->connections[i].flags;
   }
   
diff --git a/objects/ER/entity.c b/objects/ER/entity.c
index d21c936..3c664f3 100644
--- a/objects/ER/entity.c
+++ b/objects/ER/entity.c
@@ -458,7 +458,6 @@ entity_copy(Entity *entity)
     newentity->connections[i].object = newobj;
     newentity->connections[i].connected = NULL;
     newentity->connections[i].pos = entity->connections[i].pos;
-    newentity->connections[i].last_pos = entity->connections[i].last_pos;
     newentity->connections[i].flags = entity->connections[i].flags;
   }
 
diff --git a/objects/ER/relationship.c b/objects/ER/relationship.c
index b63bd46..2555df4 100644
--- a/objects/ER/relationship.c
+++ b/objects/ER/relationship.c
@@ -505,7 +505,6 @@ relationship_copy(Relationship *relationship)
     newrelationship->connections[i].object = newobj;
     newrelationship->connections[i].connected = NULL;
     newrelationship->connections[i].pos = relationship->connections[i].pos;
-    newrelationship->connections[i].last_pos = relationship->connections[i].last_pos;
   }
 
   newrelationship->font = dia_font_ref(relationship->font);
diff --git a/objects/FS/function.c b/objects/FS/function.c
index c9841f4..00accd8 100644
--- a/objects/FS/function.c
+++ b/objects/FS/function.c
@@ -505,7 +505,6 @@ function_copy(Function *pkg)
     newpkg->connections[i].object = newobj;
     newpkg->connections[i].connected = NULL;
     newpkg->connections[i].pos = pkg->connections[i].pos;
-    newpkg->connections[i].last_pos = pkg->connections[i].last_pos;
     newpkg->connections[i].flags = pkg->connections[i].flags;
   }
   newpkg->is_wish = pkg->is_wish ;
diff --git a/objects/Misc/measure.c b/objects/Misc/measure.c
index 39cf79c..5469c10 100644
--- a/objects/Misc/measure.c
+++ b/objects/Misc/measure.c
@@ -165,14 +165,14 @@ measure_load(ObjectNode obj_node, int version,DiaContext *ctx)
 }
 static PropNumData scale_range = {1e-9, 1e9, 1 };
 static PropEnumData unit_data[] = {
-  { N_("cm"), DIA_UNIT_CENTIMETER },
-  { N_("dm"), DIA_UNIT_DECIMETER },
-  { N_("ft"), DIA_UNIT_FEET },
-  { N_("in"), DIA_UNIT_INCH },
-  { N_("m"),  DIA_UNIT_METER },
-  { N_("mm"), DIA_UNIT_MILLIMETER },
-  { N_("pt"), DIA_UNIT_POINT },
-  { N_("pi"), DIA_UNIT_PICA },
+  { NC_("length unit", "cm"), DIA_UNIT_CENTIMETER },
+  { NC_("length unit", "dm"), DIA_UNIT_DECIMETER },
+  { NC_("length unit", "ft"), DIA_UNIT_FEET },
+  { NC_("length unit", "in"), DIA_UNIT_INCH },
+  { NC_("length unit", "m"),  DIA_UNIT_METER },
+  { NC_("length unit", "mm"), DIA_UNIT_MILLIMETER },
+  { NC_("length unit", "pt"), DIA_UNIT_POINT },
+  { NC_("length unit", "pi"), DIA_UNIT_PICA },
   { NULL, }
 };
 static PropNumData precision_data = {1, 9, 1};
diff --git a/objects/UML/class.c b/objects/UML/class.c
index 79db445..4b0f7b3 100644
--- a/objects/UML/class.c
+++ b/objects/UML/class.c
@@ -2080,7 +2080,6 @@ umlclass_copy(UMLClass *umlclass)
     newumlclass->connections[i].object = newobj;
     newumlclass->connections[i].connected = NULL;
     newumlclass->connections[i].pos = umlclass->connections[i].pos;
-    newumlclass->connections[i].last_pos = umlclass->connections[i].last_pos;
   }
 
   umlclass_calculate_data(newumlclass);
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index 0ba76e3..b8d27ff 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -1671,7 +1671,6 @@ custom_copy(Custom *custom)
     newcustom->connections[i].connected = NULL;
     newcustom->connections[i].pos = custom->connections[i].pos;
     newcustom->connections[i].directions = custom->connections[i].directions;
-    newcustom->connections[i].last_pos = custom->connections[i].last_pos;
     newcustom->connections[i].flags = custom->connections[i].flags;
   }
 
diff --git a/objects/standard/box.c b/objects/standard/box.c
index f950a04..b78cfad 100644
--- a/objects/standard/box.c
+++ b/objects/standard/box.c
@@ -272,7 +272,7 @@ box_move_handle(Box *box, Handle *handle,
       new_height = height;
       break;
     }
-       
+
     se_to.x = corner.x + new_width;
     se_to.y = corner.y + new_height;
         
@@ -303,7 +303,6 @@ box_draw(Box *box, DiaRenderer *renderer)
   Element *elem;
   DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer);
 
-  
   assert(box != NULL);
   assert(renderer != NULL);
 
@@ -516,7 +515,6 @@ box_copy(Box *box)
     newbox->connections[i].object = newobj;
     newbox->connections[i].connected = NULL;
     newbox->connections[i].pos = box->connections[i].pos;
-    newbox->connections[i].last_pos = box->connections[i].last_pos;
     newbox->connections[i].flags = box->connections[i].flags;
   }
 
diff --git a/objects/standard/ellipse.c b/objects/standard/ellipse.c
index d2d793b..a63e36e 100644
--- a/objects/standard/ellipse.c
+++ b/objects/standard/ellipse.c
@@ -492,7 +492,6 @@ ellipse_copy(Ellipse *ellipse)
     newellipse->connections[i].object = newobj;
     newellipse->connections[i].connected = NULL;
     newellipse->connections[i].pos = ellipse->connections[i].pos;
-    newellipse->connections[i].last_pos = ellipse->connections[i].last_pos;
     newellipse->connections[i].flags = ellipse->connections[i].flags;
   }
 
diff --git a/objects/standard/image.c b/objects/standard/image.c
index 63de47f..715e919 100644
--- a/objects/standard/image.c
+++ b/objects/standard/image.c
@@ -561,7 +561,6 @@ image_copy(Image *image)
     newimage->connections[i].object = newobj;
     newimage->connections[i].connected = NULL;
     newimage->connections[i].pos = image->connections[i].pos;
-    newimage->connections[i].last_pos = image->connections[i].last_pos;
     newimage->connections[i].flags = image->connections[i].flags;
   }
 


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