Code

* src/sp-conn-end-pair.cpp: Detach connectors from empty groups
authormjwybrow <mjwybrow@users.sourceforge.net>
Sun, 28 May 2006 04:03:35 +0000 (04:03 +0000)
committermjwybrow <mjwybrow@users.sourceforge.net>
Sun, 28 May 2006 04:03:35 +0000 (04:03 +0000)
      before trying to route connectors to them.  This is required
      since empty groups have no physical position.  Fixes bug #1448811.

ChangeLog
src/sp-conn-end-pair.cpp

index e98febc31eb56959546eb2a191359fe094428a0e..7b5fafb866f7f92fa1b659a4fe1a337fe3793688 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-28  Michael Wybrow  <mjwybrow@users.sourceforge.net>
+
+       * src/sp-conn-end-pair.cpp: Detach connectors from empty groups
+         before trying to route connectors to them.  This is required
+         since empty groups have no physical position.  Fixes bug #1448811.
+
 2006-05-27  Kees Cook  <kees@outflux.net>
 
        * src/extension/implementation/script.cpp: allow output extension
index a1c4697e55007eecbd85d90faa8ee94354303e5a..c5cc752514bd0899cd4e4ef39ee404a38164f939 100644 (file)
@@ -19,6 +19,7 @@
 #include "libavoid/vertices.h"
 #include "libavoid/router.h"
 #include "document.h"
+#include "sp-item-group.h"
 
 
 SPConnEndPair::SPConnEndPair(SPPath *const owner)
@@ -138,6 +139,20 @@ void
 SPConnEndPair::getAttachedItems(SPItem *h2attItem[2]) const {
     for (unsigned h = 0; h < 2; ++h) {
         h2attItem[h] = this->_connEnd[h]->ref.getObject();
+
+        // Deal with the case of the attached object being an empty group.
+        // A group containing no items does not have a valid bbox, so 
+        // causes problems for the auto-routing code.  Also, since such a
+        // group no longer has an onscreen representation and can only be
+        // selected through the XML editor, it makes sense just to detach
+        // connectors from them.
+        if (SP_IS_GROUP(h2attItem[h])) {
+            if (SP_GROUP(h2attItem[h])->group->getItemCount() == 0) {
+                // This group is empty, so detach.
+                sp_conn_end_detach(_path, h);
+                h2attItem[h] = NULL;
+            }
+        }
     }
 }