From 51b535dd590a1f1571f2de261e425d17b16eb0cf Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Sat, 27 Jul 2019 14:42:19 +0200 Subject: Fix #336 Connector avoid bbox of non-shapes --- src/conn-avoid-ref.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/conn-avoid-ref.cpp') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 4723d142b..0cd9eeeef 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -237,6 +237,7 @@ static std::vector approxItemWithPoints(SPItem const *item, const G { // The structure to hold the output std::vector poly_points; + SPCurve *item_curve = nullptr; if (SP_IS_GROUP(item)) { @@ -252,16 +253,24 @@ static std::vector approxItemWithPoints(SPItem const *item, const G else if (SP_IS_SHAPE(item)) { SP_SHAPE(item)->set_shape(); - SPCurve* item_curve = SP_SHAPE(item)->getCurve(); + item_curve = SP_SHAPE(item)->getCurve(); // make sure it has an associated curve if (item_curve) { // apply transformations (up to common ancestor) item_curve->transform(item_transform); - std::vector curve_points = approxCurveWithPoints(item_curve); - poly_points.insert(poly_points.end(), curve_points.begin(), curve_points.end()); - item_curve->unref(); } + } else { + auto bbox = item->documentPreferredBounds(); + if (bbox) { + item_curve = SPCurve::new_from_rect(*bbox); + } + } + + if (item_curve) { + std::vector curve_points = approxCurveWithPoints(item_curve); + poly_points.insert(poly_points.end(), curve_points.begin(), curve_points.end()); + item_curve->unref(); } return poly_points; -- cgit v1.2.3