Fix regression causing toolchange_gcode to crash Slic3r. Includes regression test.

This commit is contained in:
Alessandro Ranellucci 2013-11-24 13:04:16 +01:00
parent 5217bc370a
commit 387df3b900
4 changed files with 13 additions and 10 deletions
lib/Slic3r

View file

@ -8,6 +8,7 @@ use Slic3r::Geometry::Clipper qw(union_ex);
use Slic3r::Surface ':types';
has 'config' => (is => 'ro', required => 1);
has 'extra_variables' => (is => 'rw', default => sub {{}});
has 'extruders' => (is => 'ro', required => 1);
has 'multiple_extruders' => (is => 'lazy');
has 'standby_points' => (is => 'rw');
@ -642,7 +643,7 @@ sub set_extruder {
# append custom toolchange G-code
if (defined $self->extruder && $self->config->toolchange_gcode) {
$gcode .= sprintf "%s\n", $self->print->replace_variables($self->config->toolchange_gcode, {
$gcode .= sprintf "%s\n", $self->replace_variables($self->config->toolchange_gcode, {
previous_extruder => $self->extruder->id,
next_extruder => $extruder->id,
});
@ -741,4 +742,9 @@ sub set_bed_temperature {
return $gcode;
}
sub replace_variables {
my ($self, $string, $extra) = @_;
return $self->config->replace_options($string, { %{$self->extra_variables}, %{ $extra || {} } });
}
1;