diff --git a/lib/Slic3r/GUI/OptionsGroup.pm b/lib/Slic3r/GUI/OptionsGroup.pm index f6e63fab8..69c60114b 100644 --- a/lib/Slic3r/GUI/OptionsGroup.pm +++ b/lib/Slic3r/GUI/OptionsGroup.pm @@ -231,7 +231,9 @@ sub _build_field { }); } else { $field = Wx::TextCtrl->new($self->parent, -1, $opt->{default}, wxDefaultPosition, $size, $style); - $self->_setters->{$opt_key} = sub { $field->ChangeValue($_[0]) }; + # value supplied to the setter callback might be undef in case user loads a config + # that has empty string for multi-value options like 'wipe' + $self->_setters->{$opt_key} = sub { $field->ChangeValue($_[0]) if defined $_[0] }; EVT_TEXT($self->parent, $field, $on_change); EVT_KILL_FOCUS($field, $on_kill_focus); } diff --git a/xs/t/15_config.t b/xs/t/15_config.t index 57603ed1a..282670080 100644 --- a/xs/t/15_config.t +++ b/xs/t/15_config.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 112; +use Test::More tests => 114; foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) { $config->set('layer_height', 0.3); @@ -101,6 +101,8 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Full->new) { is $config->serialize('wipe'), '1,0', 'serialize bools'; $config->set_deserialize('wipe', '0,1,1'); is_deeply $config->get('wipe'), [0,1,1], 'deserialize bools'; + $config->set_deserialize('wipe', ''); + is_deeply $config->get('wipe'), [], 'deserialize bools from empty string'; $config->set_deserialize('retract_layer_change', 0); is_deeply $config->get('retract_layer_change'), [0], 'deserialize bools from non-string value'; {