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;
if (!exists $Options->{$key}) {
$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};
set($key, $opt->{deserialize} ? $opt->{deserialize}->($2) : $2);
}

View File

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