From 69ed69179b39747d8f51b9c68c39a39285ea4fb4 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 17 Dec 2013 16:09:07 +0100 Subject: [PATCH] Handle read_from_file() exceptions in GUI. #1619 --- lib/Slic3r/GUI/Plater.pm | 5 ++++- lib/Slic3r/GUI/SkeinPanel.pm | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 5eec59547..fef88daa2 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -384,7 +384,10 @@ sub load_file { $process_dialog->Pulse; local $SIG{__WARN__} = Slic3r::GUI::warning_catcher($self); - my $model = Slic3r::Model->read_from_file($input_file); + + my $model = eval { Slic3r::Model->read_from_file($input_file) }; + Slic3r::GUI::show_error($self, $@) if $@; + for my $i (0 .. $#{$model->objects}) { my $object = Slic3r::GUI::Plater::Object->new( name => $basename, diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 2ea3dd765..20e573d51 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -133,8 +133,11 @@ sub quick_slice { $Slic3r::GUI::Settings->{recent}{skein_directory} = dirname($input_file); Slic3r::GUI->save_settings; + my $model = eval { Slic3r::Model->read_from_file($input_file) }; + Slic3r::GUI::show_error($self, $@) if $@; + my $print = $self->init_print; - $print->add_model(Slic3r::Model->read_from_file($input_file)); + $print->add_model($model); $print->validate; # select output file @@ -364,7 +367,9 @@ sub combine_stls { $output_file = $dlg->GetPath; } - my @models = map Slic3r::Model->read_from_file($_), @input_files; + my @models = eval { map Slic3r::Model->read_from_file($_), @input_files }; + Slic3r::GUI::show_error($self, $@) if $@; + my $new_model = Slic3r::Model->new; my $new_object = $new_model->add_object; for my $m (0 .. $#models) {