Don't die when config has unknown options. #108

This commit is contained in:
Alessandro Ranellucci 2011-12-10 10:39:07 +01:00
parent c957c27367
commit 0ebd8eb8a9
2 changed files with 12 additions and 6 deletions

View file

@ -315,8 +315,9 @@ sub load {
my $key = $1; my $key = $1;
if (!exists $Options->{$key}) { if (!exists $Options->{$key}) {
$key = +(grep { $Options->{$_}{aliases} && grep $_ eq $key, @{$Options->{$_}{aliases}} } $key = +(grep { $Options->{$_}{aliases} && grep $_ eq $key, @{$Options->{$_}{aliases}} }
keys %$Options)[0] or die "Unknown option $1 at line $.\n"; keys %$Options)[0] or warn "Unknown option $1 at line $.\n";
} }
next unless $key;
my $opt = $Options->{$key}; my $opt = $Options->{$key};
set($key, $opt->{deserialize} ? $opt->{deserialize}->($2) : $2); set($key, $opt->{deserialize} ? $opt->{deserialize}->($2) : $2);
} }

View file

@ -159,11 +159,7 @@ sub do_slice {
}, },
); );
{ {
local $SIG{__WARN__} = sub { local $SIG{__WARN__} = $self->catch_warning;
my $message = shift;
Wx::MessageDialog->new($self, $message, 'Warning',
wxOK | wxICON_WARNING)->ShowModal;
};
$skein->go; $skein->go;
} }
$process_dialog->Destroy; $process_dialog->Destroy;
@ -205,6 +201,7 @@ sub load_config {
my ($file) = $dlg->GetPaths; my ($file) = $dlg->GetPaths;
$last_dir = dirname($file); $last_dir = dirname($file);
eval { eval {
local $SIG{__WARN__} = $self->catch_warning;
Slic3r::Config->load($file); Slic3r::Config->load($file);
}; };
$self->catch_error(); $self->catch_error();
@ -220,4 +217,12 @@ sub catch_error {
} }
} }
sub catch_warning {
my ($self) = @_;
return sub {
my $message = shift;
Wx::MessageDialog->new($self, $message, 'Warning', wxOK | wxICON_WARNING)->ShowModal;
};
};
1; 1;