From 60f0ca52e3b3a61539cc5eae521a2b8bd16d4448 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 15 May 2017 22:54:20 +0200 Subject: [PATCH] Fix regression with non-ASCII paths on Windows. We'll need to work more on this when porting stuff to C++. #2955 --- lib/Slic3r/GUI/BedShapeDialog.pm | 2 +- lib/Slic3r/GUI/MainFrame.pm | 2 +- lib/Slic3r/GUI/Plater.pm | 4 ++-- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 2 +- slic3r.pl | 18 +++++++++--------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Slic3r/GUI/BedShapeDialog.pm b/lib/Slic3r/GUI/BedShapeDialog.pm index 1ef787e70..a336b40e7 100644 --- a/lib/Slic3r/GUI/BedShapeDialog.pm +++ b/lib/Slic3r/GUI/BedShapeDialog.pm @@ -289,7 +289,7 @@ sub _load_stl { my $input_file = Slic3r::decode_path($dialog->GetPaths); $dialog->Destroy; - my $model = Slic3r::Model->read_from_file($input_file); + my $model = Slic3r::Model->read_from_file(Slic3r::encode_path($input_file)); my $mesh = $model->raw_mesh; my $expolygons = $mesh->horizontal_projection; diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 9eec4d625..dc04b39d5 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -384,7 +384,7 @@ sub quick_slice { ); # keep model around - my $model = Slic3r::Model->read_from_file($input_file); + my $model = Slic3r::Model->read_from_file(Slic3r::encode_path($input_file)); $sprint->apply_config($config); $sprint->set_model($model); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 2cd8e52af..4d2ce292d 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -816,7 +816,7 @@ sub add_tin { return if $offset < 0; foreach my $input_file (@input_files) { - my $model = eval { Slic3r::Model->read_from_file($input_file) }; + my $model = eval { Slic3r::Model->read_from_file(Slic3r::encode_path($input_file)) }; Slic3r::GUI::show_error($self, $@) if $@; next if !$model; @@ -847,7 +847,7 @@ sub load_file { local $SIG{__WARN__} = Slic3r::GUI::warning_catcher($self); - my $model = eval { Slic3r::Model->read_from_file($input_file) }; + my $model = eval { Slic3r::Model->read_from_file(Slic3r::encode_path($input_file)) }; Slic3r::GUI::show_error($self, $@) if $@; my @obj_idx = (); diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index e0fe90f6e..bc3c7d0b8 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -350,7 +350,7 @@ sub on_btn_load { my @input_files = wxTheApp->open_model($self); foreach my $input_file (@input_files) { - my $model = eval { Slic3r::Model->read_from_file($input_file) }; + my $model = eval { Slic3r::Model->read_from_file(Slic3r::encode_path($input_file)) }; if ($@) { Slic3r::GUI::show_error($self, $@); next; diff --git a/slic3r.pl b/slic3r.pl index a21509843..a97dcca81 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -74,9 +74,9 @@ my @external_configs = (); if ($opt{load}) { foreach my $configfile (@{$opt{load}}) { $configfile = Slic3r::decode_path($configfile); - if (-e $configfile) { + if (-e Slic3r::encode_path($configfile)) { push @external_configs, Slic3r::Config->load($configfile); - } elsif (-e "$FindBin::Bin/$configfile") { + } elsif (-e Slic3r::encode_path("$FindBin::Bin/$configfile")) { printf STDERR "Loading $FindBin::Bin/$configfile\n"; push @external_configs, Slic3r::Config->load("$FindBin::Bin/$configfile"); } else { @@ -99,7 +99,7 @@ if ($opt{save}) { if (@{$config->get_keys} > 0) { $config->save($opt{save}); } else { - Slic3r::Config->new_from_defaults->save($opt{save}); + Slic3r::Config->new_from_defaults->save(Slic3r::decode_path($opt{save})); } } @@ -154,7 +154,7 @@ if (@ARGV) { # slicing from command line if ($opt{cut}) { foreach my $file (@ARGV) { $file = Slic3r::decode_path($file); - my $model = Slic3r::Model->read_from_file($file); + my $model = Slic3r::Model->read_from_file(Slic3r::encode_path($file)); $model->add_default_instances; my $mesh = $model->mesh; $mesh->translate(0, 0, -$mesh->bounding_box->z_min); @@ -175,7 +175,7 @@ if (@ARGV) { # slicing from command line my ($grid_x, $grid_y) = split /[,x]/, $opt{cut_grid}, 2; foreach my $file (@ARGV) { $file = Slic3r::decode_path($file); - my $model = Slic3r::Model->read_from_file($file); + my $model = Slic3r::Model->read_from_file(Slic3r::encode_path($file)); $model->add_default_instances; my $mesh = $model->mesh; my $bb = $mesh->bounding_box; @@ -217,7 +217,7 @@ if (@ARGV) { # slicing from command line if ($opt{split}) { foreach my $file (@ARGV) { $file = Slic3r::decode_path($file); - my $model = Slic3r::Model->read_from_file($file); + my $model = Slic3r::Model->read_from_file(Slic3r::encode_path($file)); $model->add_default_instances; my $mesh = $model->mesh; $mesh->repair; @@ -236,10 +236,10 @@ if (@ARGV) { # slicing from command line $input_file = Slic3r::decode_path($input_file); my $model; if ($opt{merge}) { - my @models = map Slic3r::Model->read_from_file($_), $input_file, (splice @ARGV, 0); + my @models = map Slic3r::Model->read_from_file($_), Slic3r::encode_path($input_file), (splice @ARGV, 0); $model = Slic3r::Model->merge(@models); } else { - $model = Slic3r::Model->read_from_file($input_file); + $model = Slic3r::Model->read_from_file(Slic3r::encode_path($input_file)); } $model->repair; @@ -266,7 +266,7 @@ if (@ARGV) { # slicing from command line my ($percent, $message) = @_; printf "=> %s\n", $message; }, - output_file => $opt{output}, + output_file => Slic3r::decode_path($opt{output}), ); $sprint->apply_config($config);