From e4c9171890ec56b786bc6fc75af89f730e9c5551 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 17 Dec 2013 16:12:44 +0100 Subject: [PATCH] Handle read_from_file() exceptions in GUI. #1619 --- lib/Slic3r/GUI/Plater.pm | 5 ++++- lib/Slic3r/GUI/SkeinPanel.pm | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ba59114a1..08dbaddef 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -383,7 +383,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 $@; + $self->load_model_object($_) for @{$model->objects}; $process_dialog->Destroy; diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index 8dc1df827..d48818313 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -134,7 +134,8 @@ sub quick_slice { Slic3r::GUI->save_settings; my $print = $self->init_print; - 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 $@; if ($model->has_objects_with_no_instances) { # apply a default position to all objects not having one @@ -370,7 +371,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) {