From 037be34b7b7e42eb1b888a94831ad1d3fcf97642 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci <aar@cpan.org> Date: Fri, 21 Sep 2012 16:52:05 +0200 Subject: [PATCH] Bugfix: removed fatal error when generating SVG support material in some circumstances. #673 --- lib/Slic3r/Geometry.pm | 1 + lib/Slic3r/Print.pm | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Geometry.pm b/lib/Slic3r/Geometry.pm index 3c884e934..7b66d40e9 100644 --- a/lib/Slic3r/Geometry.pm +++ b/lib/Slic3r/Geometry.pm @@ -242,6 +242,7 @@ sub polygon_lines { sub nearest_point { my ($point, $points) = @_; my $index = nearest_point_index(@_); + return undef if !defined $index; return $points->[$index]; } diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 8accf1dd9..e81243f45 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -462,7 +462,8 @@ EOF foreach my $expolygon (@unsupported_slices) { # look for the nearest point to this island among all # supported points - my $support_point = nearest_point($expolygon->contour->[0], \@supported_points); + my $support_point = nearest_point($expolygon->contour->[0], \@supported_points) + or next; my $anchor_point = nearest_point($support_point, $expolygon->contour->[0]); printf $fh qq{ <line x1="%s" y1="%s" x2="%s" y2="%s" style="stroke-width: 2; stroke: white" />\n}, map @$_, $support_point, $anchor_point;