diff -Nru dia-0.97.2/lib/object.c dia-0.97.2_modified/lib/object.c
--- dia-0.97.2/lib/object.c	2009-11-07 18:13:53.000000000 +0100
+++ dia-0.97.2_modified/lib/object.c	2013-02-06 17:53:56.960013572 +0100
@@ -132,6 +132,24 @@
   return GPOINTER_TO_UINT(some_pointer);
 }
 
+/*
+ * mad, mad, hack.
+ * this makes properties (esp. connections) of objects in nested groups being copied properly
+ * this is not thread-safe, this is not safe for independent lists, ...
+ */
+
+/*
+ * additionally i found a bug concerning the connections
+ * reproduce that way:
+ * add two rectangles
+ * add a line, connect to one of the rectangles
+ * group the two rectangles
+ * delete the group
+ * then you will see that the connection is not deleted in the group (red box)
+ * if you store now, the connection will be in the file
+ */
+GHashTable *hash_table;
+gint hash_table_of_nestedgroupsorothercomposites = 0;
 
 /** Copy a list of objects, keeping connections and parent-children
  *  relation ships between the objects.  It is assumed that the 
@@ -150,9 +168,12 @@
   GList *list;
   DiaObject *obj;
   DiaObject *obj_copy;
-  GHashTable *hash_table;
+  /* this line is commented out for the mad, mad, hack
+  GHashTable *hash_table; */
   int i;
 
+  /* this two lines belong to the mad, mad, hack */
+  if (hash_table_of_nestedgroupsorothercomposites++ == 0)
   hash_table = g_hash_table_new((GHashFunc) pointer_hash, NULL);
 
   /* First ops->copy the entire list */
@@ -172,6 +193,10 @@
 
   /* Rebuild the connections and parent/child references between the
   objects in the list: */
+  /* the mad, mad, hack should work without any modifications here
+     thats because the copies and checks are made on all nesting-layers
+     using a complete hash-table (containing the objects from all nesting layers) */
+
   list = list_orig;
   while (list != NULL) {
     obj = (DiaObject *)list->data;
@@ -232,6 +257,8 @@
     list = g_list_next(list);
   }
   
+  /* this two lines belong to the mad, mad, hack */
+  if (--hash_table_of_nestedgroupsorothercomposites == 0)
   g_hash_table_destroy(hash_table);
   
   return list_copy;


diff -Nru dia-0.97.2/app/diagram.c dia-0.97.2_modified/app/diagram.c
--- dia-0.97.2/app/diagram.c	2009-11-07 18:13:53.000000000 +0100
+++ dia-0.97.2_modified/app/diagram.c	2013-02-06 18:06:10.880045573 +0100
@@ -1196,6 +1196,28 @@
   }
 }
 
+/* not so mad hack:
+ * makes the grouping-command not stripping connections
+ * between different nesting-layers of groups
+ * 
+ * this function is added: */
+/* collect all objects */
+static GList* addRecursively(GList* to, GList* from)
+{
+	    GList *it = from;
+		while (it != NULL) {
+			DiaObject *selobj = (DiaObject*) it->data;
+			to = g_list_append(to, selobj);
+
+			if(IS_GROUP(selobj))
+			{
+				addRecursively(to, group_objects(selobj));
+			}
+			it = g_list_next(it);
+		}
+		return to;
+}
+
 void diagram_group_selected(Diagram *dia)
 {
   GList *list;
@@ -1204,6 +1226,10 @@
   DiaObject *obj;
   GList *orig_list;
   Change *change;
+  /* not so mad hack:
+   * declare the list for the objects to which connections do not have to be stripped
+   */
+  GList *not_strip;
 
   if (g_list_length(dia->data->selected) < 1) {
     message_error(_("Trying to group with no selected objects."));
@@ -1241,7 +1267,14 @@
   /* We have to rebuild the selection list so that it is the same
      order as in the Diagram list. */
   group_list = diagram_get_sorted_selected_remove(dia);
-  
+
+  /* not so mad hack:
+   * use the comlete content list instead of dia->data->selected
+   */
+  not_strip = g_list_alloc();
+  not_strip = addRecursively(not_strip, dia->data->selected);
+  /* end modification */
+
   list = group_list;
   while (list != NULL) {
     obj = (DiaObject *)list->data;
@@ -1249,11 +1282,20 @@
     /* Remove connections from obj to objects outside created group. */
     /* strip_connections sets up its own undo info. */
     /* The connections aren't reattached by ungroup. */
-    strip_connections(obj, dia->data->selected, dia);
+
+    /* not so mad hack:
+     * use the comlete content list "not_strip" instead of dia->data->selected
+     */
+    strip_connections(obj, not_strip, dia);
     
     list = g_list_next(list);
   }
 
+  /* not so mad hack:
+   * free the comlete content list
+   */
+  g_list_free(not_strip);
+
   /* Remove list of selected objects */
   textedit_remove_focus_all(dia);
   data_remove_all_selected(dia->data);
