Skip to content

Commit

Permalink
Fixed regression causing [input_filename] and [input_filename_base] n…
Browse files Browse the repository at this point in the history
…ot being available in custom G-code anymore. Includes regression test. #1507
  • Loading branch information
alranel committed Feb 15, 2015
1 parent c0f453f commit a07c48b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/Slic3r/Print.pm
Expand Up @@ -428,10 +428,10 @@ sub expanded_output_filepath {

my $filename = my $filename_base = basename($input_file);
$filename_base =~ s/\.[^.]+$//; # without suffix
my $extra = {
input_filename => $filename,
input_filename_base => $filename_base,
};

# set filename in placeholder parser so that it's available also in custom G-code
$self->placeholder_parser->set(input_filename => $filename);
$self->placeholder_parser->set(input_filename_base => $filename_base);

if ($path && -d $path) {
# if output path is an existing directory, we take that and append
Expand All @@ -447,7 +447,7 @@ sub expanded_output_filepath {

# make sure we use an up-to-date timestamp
$self->placeholder_parser->update_timestamp;
return $self->placeholder_parser->process($path, $extra);
return $self->placeholder_parser->process($path);
}

# This method assigns extruders to the volumes having a material
Expand Down
10 changes: 9 additions & 1 deletion t/gcode.t
@@ -1,4 +1,4 @@
use Test::More tests => 20;
use Test::More tests => 21;
use strict;
use warnings;

Expand Down Expand Up @@ -184,4 +184,12 @@ use Slic3r::Test;
}
}

{
my $config = Slic3r::Config->new_from_defaults;
$config->set('start_gcode', 'START:[input_filename]');
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
my $gcode = Slic3r::Test::gcode($print);
like $gcode, qr/START:20mm_cube/, '[input_filename] is also available in custom G-code';
}

__END__

0 comments on commit a07c48b

Please sign in to comment.