Fixed regression in the post_process GUI field. #3698

This commit is contained in:
Alessandro Ranellucci 2017-03-05 16:13:19 +01:00
parent 69202aeeb9
commit 871f469c89
3 changed files with 19 additions and 23 deletions

View File

@ -350,7 +350,7 @@ sub get_option {
$self->_opt_map->{$opt_id} = [ $opt_key, $opt_index ];
my $optdef = $Slic3r::Config::Options->{$opt_key}; # we should access this from $self->config
my $default_value = $self->_get_config_value($opt_key, $opt_index, $optdef->{gui_flags} =~ /\bserialized\b/);
my $default_value = $self->_get_config_value($opt_key, $opt_index, $optdef->{type} eq 's@');
return Slic3r::GUI::OptionsGroup::Option->new(
opt_id => $opt_id,
@ -395,7 +395,7 @@ sub reload_config {
foreach my $opt_id (keys %{ $self->_opt_map }) {
my ($opt_key, $opt_index) = @{ $self->_opt_map->{$opt_id} };
my $option = $self->_options->{$opt_id};
$self->set_value($opt_id, $self->_get_config_value($opt_key, $opt_index, $option->gui_flags =~ /\bserialized\b/));
$self->set_value($opt_id, $self->_get_config_value($opt_key, $opt_index, $option->type eq 's@'));
}
}
@ -409,15 +409,16 @@ sub get_fieldc {
}
sub _get_config_value {
my ($self, $opt_key, $opt_index, $deserialize) = @_;
my ($self, $opt_key, $opt_index, $as_string) = @_;
if ($deserialize) {
die "Can't deserialize option indexed value" if $opt_index != -1;
return $self->config->serialize($opt_key);
if ($opt_index == -1) {
my $value = $self->config->get($opt_key);
if ($as_string && ref($value) eq 'ARRAY') {
return join "\n", @$value;
}
return $value;
} else {
return $opt_index == -1
? $self->config->get($opt_key)
: $self->config->get_at($opt_key, $opt_index);
return $self->config->get_at($opt_key, $opt_index);
}
}
@ -430,17 +431,15 @@ sub _on_change {
# get value
my $field_value = $self->get_value($opt_id);
if ($option->gui_flags =~ /\bserialized\b/) {
die "Can't set serialized option indexed value" if $opt_index != -1;
$self->config->set_deserialize($opt_key, $field_value);
} else {
if ($opt_index == -1) {
$self->config->set($opt_key, $field_value);
} else {
my $value = $self->config->get($opt_key);
$value->[$opt_index] = $field_value;
$self->config->set($opt_key, $value);
if ($opt_index == -1) {
if ($option->type eq 's@' && ref($field_value) ne 'ARRAY') {
$field_value = [ split /(?<!\\)[;\n]/, $field_value ];
}
$self->config->set($opt_key, $field_value);
} else {
my $value = $self->config->get($opt_key);
$value->[$opt_index] = $field_value;
$self->config->set($opt_key, $value);
}
}

View File

@ -565,9 +565,7 @@ class ConfigOptionDef
// Special values - "i_enum_open", "f_enum_open" to provide combo box for int or float selection,
// "select_open" - to open a selection dialog (currently only a serial port selection).
std::string gui_type;
// Usually empty. Otherwise "serialized" or "show_value"
// The flags may be combined.
// "serialized" - vector valued option is entered in a single edit field. Values are separated by a semicolon.
// "show_value" - even if enum_values / enum_labels are set, still display the value, not the enum label.
// "align_label_right" - align label to right
std::string gui_flags;

View File

@ -816,9 +816,8 @@ PrintConfigDef::PrintConfigDef()
def = this->add("post_process", coStrings);
def->label = "Post-processing scripts";
def->tooltip = "If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts with a semicolon. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables.";
def->tooltip = "If you want to process the output G-code through custom scripts, just list their absolute paths here. Separate multiple scripts on individual lines. Scripts will be passed the absolute path to the G-code file as the first argument, and they can access the Slic3r config settings by reading environment variables.";
def->cli = "post-process=s@";
def->gui_flags = "serialized";
def->multiline = true;
def->full_width = true;
def->height = 60;