Skip to content

Commit

Permalink
Bugfix: when an external config was selected in any section, exported…
Browse files Browse the repository at this point in the history
… settings didn't reflect other sections properly
  • Loading branch information
alranel committed Aug 8, 2012
1 parent 2f2bc82 commit 4fcecf5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 3 additions & 1 deletion lib/Slic3r/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,9 @@ sub new_from_cli {

sub merge {
my $class = shift;
return $class->new(map %$_, @_);
my $config = $class->new;
$config->apply($_) for @_;
return $config;
}

sub load {
Expand Down
26 changes: 16 additions & 10 deletions lib/Slic3r/GUI/SkeinPanel.pm
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,22 @@ sub config {

# retrieve filament presets and build a single config object for them
my $filament_config;
foreach my $preset_idx ($self->{plater}->filament_presets) {
my $preset = $self->{options_tabs}{filament}->get_preset($preset_idx);
my $config = $self->{options_tabs}{filament}->get_preset_config($preset);
if (!$filament_config) {
$filament_config = $config;
next;
}
foreach my $opt_key (keys %$config) {
next unless ref $filament_config->get($opt_key) eq 'ARRAY';
push @{ $filament_config->get($opt_key) }, $config->get($opt_key)->[0];
if ($self->{plater}->filament_presets == 1) {
$filament_config = $self->{options_tabs}{filament}->config;
} else {
# TODO: handle dirty presets.
# perhaps plater shouldn't expose dirty presets at all in multi-extruder environments.
foreach my $preset_idx ($self->{plater}->filament_presets) {
my $preset = $self->{options_tabs}{filament}->get_preset($preset_idx);
my $config = $self->{options_tabs}{filament}->get_preset_config($preset);
if (!$filament_config) {
$filament_config = $config;
next;
}
foreach my $opt_key (keys %$config) {
next unless ref $filament_config->get($opt_key) eq 'ARRAY';
push @{ $filament_config->get($opt_key) }, $config->get($opt_key)->[0];
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Slic3r/GUI/Tab.pm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ sub get_preset_config {
}

# apply preset values on top of defaults
$config->apply(Slic3r::Config->load($preset->{file}));
my $external_config = Slic3r::Config->load($preset->{file});
$config->set($_, $external_config->get($_)) for @{$self->{options}};
}

return $config;
Expand Down

1 comment on commit 4fcecf5

@henrikbrixandersen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit breaks loading all my config files:
Use of uninitialized value in subroutine entry at /Users/brix/Projects/github/Slic3r/lib/Slic3r/GUI/OptionsGroup.pm line 119.

Please sign in to comment.