Code

Filter effects dialog:
[inkscape.git] / src / sp-conn-end.cpp
index af8692358ea2877de0ce25b763c74ba699639e00..dd64975262b2a430806f673b167ecd8bd98822de 100644 (file)
@@ -38,11 +38,11 @@ sp_conn_end_move_compensate(NR::Matrix const *mp, SPItem *moved_item,
                             SPPath *const path,
                             bool const updatePathRepr = true)
 {
-    // TODO: SPItem::invokeBbox gives the wrong result for some objects
+    // TODO: SPItem::getBounds gives the wrong result for some objects
     //       that have internal representations that are updated later
     //       by the sp_*_update functions, e.g., text.
     sp_document_ensure_up_to_date(path->document);
-    
+
     // Get the new route around obstacles.
     path->connEndPair.reroutePath();
 
@@ -64,15 +64,21 @@ sp_conn_end_move_compensate(NR::Matrix const *mp, SPItem *moved_item,
         /* Initial end-points: centre of attached object. */
         NR::Point h2endPt_icoordsys[2];
         NR::Matrix h2i2anc[2];
-        NR::Rect h2bbox_icoordsys[2] = {
-            h2attItem[0]->invokeBbox(NR::identity()),
-            h2attItem[1]->invokeBbox(NR::identity())
-        };
+        NR::Rect h2bbox_icoordsys[2];
         NR::Point last_seg_endPt[2] = {
             sp_curve_second_point(path->curve),
             sp_curve_penultimate_point(path->curve)
         };
         for (unsigned h = 0; h < 2; ++h) {
+            NR::Maybe<NR::Rect> bbox = h2attItem[h]->getBounds(NR::identity());
+            if (!bbox) {
+                if (updatePathRepr) {
+                    path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+                    path->updateRepr();
+                }
+                return;
+            }
+            h2bbox_icoordsys[h] = *bbox;
             h2i2anc[h] = i2anc_affine(h2attItem[h], ancestor);
             h2endPt_icoordsys[h] = h2bbox_icoordsys[h].midpoint();
         }
@@ -107,11 +113,19 @@ sp_conn_end_move_compensate(NR::Matrix const *mp, SPItem *moved_item,
 
         NR::Rect otherpt_rect = NR::Rect(other_endpt, other_endpt);
         NR::Rect h2bbox_icoordsys[2] = { otherpt_rect, otherpt_rect };
-        h2bbox_icoordsys[ind] = h2attItem[ind]->invokeBbox(NR::identity());
-        
+        NR::Maybe<NR::Rect> bbox = h2attItem[ind]->getBounds(NR::identity());
+        if (!bbox) {
+            if (updatePathRepr) {
+                path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+                path->updateRepr();
+            }
+            return;
+        }
+
+        h2bbox_icoordsys[ind] = *bbox;
         h2i2anc = i2anc_affine(h2attItem[ind], ancestor);
         h2endPt_icoordsys[ind] = h2bbox_icoordsys[ind].midpoint();
-        
+
         h2endPt_icoordsys[!ind] = other_endpt;
 
         // For the attached object, change the corresponding point to be
@@ -120,10 +134,10 @@ sp_conn_end_move_compensate(NR::Matrix const *mp, SPItem *moved_item,
         h2endPt_icoordsys[ind] = calc_bbox_conn_pt(h2bbox_icoordsys[ind],
                                                  ( last_seg_pt / h2i2anc ));
         h2endPt_pcoordsys[ind] = h2endPt_icoordsys[ind] * h2i2anc / path2anc;
-        
+
         // Leave the other where it is.
         h2endPt_pcoordsys[!ind] = other_endpt;
-        
+
         change_endpts(path->curve, h2endPt_pcoordsys);
     }
     if (updatePathRepr) {
@@ -236,7 +250,7 @@ sp_conn_end_detach(SPObject *const owner, unsigned const handle_ix)
 
 void
 SPConnEnd::setAttacherHref(gchar const *value)
-{    
+{
     if ( value && href && ( strcmp(value, href) == 0 ) ) {
         /* No change, do nothing. */
     } else {