From 23848492ce78aa4f69df94ce6d78b1abb0846922 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 26 Nov 2014 22:46:51 +0100 Subject: [PATCH] Fixed regression causing crash when using avoid_crossing_perimeters with multiple object, caused by recent refactorings. Added regression test --- lib/Slic3r/GCode.pm | 4 +++- t/avoid_crossing_perimeters.t | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 t/avoid_crossing_perimeters.t diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 0561e4cd8..c8b72a8ad 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -560,6 +560,8 @@ has '_layer_mp' => (is => 'rw'); has 'new_object' => (is => 'rw', default => sub {0}); # this flag triggers the use of the external configuration space for avoid_crossing_perimeters for the next travel move has 'straight_once' => (is => 'rw', default => sub {1}); # this flag disables avoid_crossing_perimeters just for the next travel move +use Slic3r::Geometry qw(scale); + sub init_external_mp { my ($self, $islands) = @_; $self->_external_mp(Slic3r::MotionPlanner->new($islands)); @@ -612,7 +614,7 @@ sub _plan { # append the actual path and return # use G1 because we rely on paths being straight (G0 may make round paths) $gcode .= join '', - map $gcodegen->writer->travel_to_xy($self->point_to_gcode($_->b), $comment), + map $gcodegen->writer->travel_to_xy($gcodegen->point_to_gcode($_->b), $comment), @{$travel->lines}; return $gcode; diff --git a/t/avoid_crossing_perimeters.t b/t/avoid_crossing_perimeters.t new file mode 100644 index 000000000..dd6c3e7b6 --- /dev/null +++ b/t/avoid_crossing_perimeters.t @@ -0,0 +1,21 @@ +use Test::More tests => 1; +use strict; +use warnings; + +BEGIN { + use FindBin; + use lib "$FindBin::Bin/../lib"; +} + +use List::Util qw(first sum); +use Slic3r; +use Slic3r::Test; + +{ + my $config = Slic3r::Config->new_from_defaults; + $config->set('avoid_crossing_perimeters', 2); + my $print = Slic3r::Test::init_print('20mm_cube', config => $config, duplicate => 2); + ok my $gcode = Slic3r::Test::gcode($print), "no crash with avoid_crossing_perimeters and multiple objects"; +} + +__END__