Unicode handling:
Removed the Perl dependencies on Encode, Encode::Locale and Unicode::Normalize. Added dependency on boost::locale. Added encode_path, decode_path, normalize_utf8 functions to Slic3r.xs Slic3r.xs has been made mostly utf8 safe by using the boost::nowide library, thanks to @alexrj for the idea. Simplified the encode_path / decode_path stuff: wxWidgets are unicode already, so there is no need to decode_path() from it. Perl / win32 interfacing is non-unicode, so decode_path() is executed on ARGV just at the beginning of the perl scripts.
This commit is contained in:
parent
31085fb1d7
commit
1385018724
33 changed files with 236 additions and 186 deletions
|
@ -286,7 +286,7 @@ sub _load_stl {
|
|||
$dialog->Destroy;
|
||||
return;
|
||||
}
|
||||
my $input_file = Slic3r::decode_path($dialog->GetPaths);
|
||||
my $input_file = $dialog->GetPaths;
|
||||
$dialog->Destroy;
|
||||
|
||||
my $model = Slic3r::Model->read_from_file($input_file);
|
||||
|
|
|
@ -368,7 +368,7 @@ sub quick_slice {
|
|||
$dialog->Destroy;
|
||||
return;
|
||||
}
|
||||
$input_file = Slic3r::decode_path($dialog->GetPaths);
|
||||
$input_file = $dialog->GetPaths;
|
||||
$dialog->Destroy;
|
||||
$qs_last_input_file = $input_file unless $params{export_svg};
|
||||
} else {
|
||||
|
@ -428,7 +428,7 @@ sub quick_slice {
|
|||
$dlg->Destroy;
|
||||
return;
|
||||
}
|
||||
$output_file = Slic3r::decode_path($dlg->GetPath);
|
||||
$output_file = $dlg->GetPath;
|
||||
$qs_last_output_file = $output_file unless $params{export_svg};
|
||||
$Slic3r::GUI::Settings->{_}{last_output_path} = dirname($output_file);
|
||||
wxTheApp->save_settings;
|
||||
|
@ -482,7 +482,7 @@ sub repair_stl {
|
|||
$dialog->Destroy;
|
||||
return;
|
||||
}
|
||||
$input_file = Slic3r::decode_path($dialog->GetPaths);
|
||||
$input_file = $dialog->GetPaths;
|
||||
$dialog->Destroy;
|
||||
}
|
||||
|
||||
|
@ -495,14 +495,14 @@ sub repair_stl {
|
|||
$dlg->Destroy;
|
||||
return undef;
|
||||
}
|
||||
$output_file = Slic3r::decode_path($dlg->GetPath);
|
||||
$output_file = $dlg->GetPath;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
|
||||
my $tmesh = Slic3r::TriangleMesh->new;
|
||||
$tmesh->ReadSTLFile(Slic3r::encode_path($input_file));
|
||||
$tmesh->ReadSTLFile($input_file);
|
||||
$tmesh->repair;
|
||||
$tmesh->WriteOBJFile(Slic3r::encode_path($output_file));
|
||||
$tmesh->WriteOBJFile($output_file);
|
||||
Slic3r::GUI::show_info($self, "Your file was repaired.", "Repair");
|
||||
}
|
||||
|
||||
|
@ -529,7 +529,7 @@ sub export_config {
|
|||
my $dlg = Wx::FileDialog->new($self, 'Save configuration as:', $dir, $filename,
|
||||
&Slic3r::GUI::FILE_WILDCARDS->{ini}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ($dlg->ShowModal == wxID_OK) {
|
||||
my $file = Slic3r::decode_path($dlg->GetPath);
|
||||
my $file = $dlg->GetPath;
|
||||
$Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file);
|
||||
wxTheApp->save_settings;
|
||||
$last_config = $file;
|
||||
|
@ -548,7 +548,7 @@ sub load_config_file {
|
|||
my $dlg = Wx::FileDialog->new($self, 'Select configuration to load:', $dir, "config.ini",
|
||||
'INI files (*.ini, *.gcode)|*.ini;*.INI;*.gcode;*.g', wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
return unless $dlg->ShowModal == wxID_OK;
|
||||
$file = Slic3r::decode_path($dlg->GetPaths);
|
||||
$file = $dlg->GetPaths;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
for my $tab (values %{$self->{options_tabs}}) {
|
||||
|
@ -574,7 +574,7 @@ sub export_configbundle {
|
|||
my $dlg = Wx::FileDialog->new($self, 'Save presets bundle as:', $dir, $filename,
|
||||
&Slic3r::GUI::FILE_WILDCARDS->{ini}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ($dlg->ShowModal == wxID_OK) {
|
||||
my $file = Slic3r::decode_path($dlg->GetPath);
|
||||
my $file = $dlg->GetPath;
|
||||
$Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file);
|
||||
wxTheApp->save_settings;
|
||||
|
||||
|
@ -604,7 +604,7 @@ sub load_configbundle {
|
|||
my $dlg = Wx::FileDialog->new($self, 'Select configuration to load:', $dir, "config.ini",
|
||||
&Slic3r::GUI::FILE_WILDCARDS->{ini}, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
return unless $dlg->ShowModal == wxID_OK;
|
||||
$file = Slic3r::decode_path($dlg->GetPaths);
|
||||
$file = $dlg->GetPaths;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
|
||||
|
|
|
@ -1408,7 +1408,7 @@ sub export_gcode {
|
|||
$dlg->Destroy;
|
||||
return;
|
||||
}
|
||||
my $path = Slic3r::decode_path($dlg->GetPath);
|
||||
my $path = $dlg->GetPath;
|
||||
$Slic3r::GUI::Settings->{_}{last_output_path} = dirname($path);
|
||||
wxTheApp->save_settings;
|
||||
$self->{export_gcode_output_file} = $path;
|
||||
|
@ -1574,7 +1574,7 @@ sub send_gcode {
|
|||
my $ua = LWP::UserAgent->new;
|
||||
$ua->timeout(180);
|
||||
|
||||
my $path = Slic3r::encode_path($self->{send_gcode_file});
|
||||
my $enc_path = Slic3r::encode_path($self->{send_gcode_file});
|
||||
my $res = $ua->post(
|
||||
"http://" . $self->{config}->octoprint_host . "/api/files/local",
|
||||
Content_Type => 'form-data',
|
||||
|
@ -1582,7 +1582,7 @@ sub send_gcode {
|
|||
Content => [
|
||||
# OctoPrint doesn't like Windows paths so we use basename()
|
||||
# Also, since we need to read from filesystem we process it through encode_path()
|
||||
file => [ $path, basename($path) ],
|
||||
file => [ $enc_path, basename($enc_path) ],
|
||||
],
|
||||
);
|
||||
|
||||
|
@ -1603,7 +1603,7 @@ sub export_stl {
|
|||
return if !@{$self->{objects}};
|
||||
|
||||
my $output_file = $self->_get_export_file('STL') or return;
|
||||
$self->{model}->store_stl(Slic3r::encode_path($output_file), 1);
|
||||
$self->{model}->store_stl($output_file, 1);
|
||||
$self->statusbar->SetStatusText("STL file exported to $output_file");
|
||||
}
|
||||
|
||||
|
@ -1644,7 +1644,7 @@ sub export_object_stl {
|
|||
my $model_object = $self->{model}->objects->[$obj_idx];
|
||||
|
||||
my $output_file = $self->_get_export_file('STL') or return;
|
||||
$model_object->mesh->write_binary(Slic3r::encode_path($output_file));
|
||||
$model_object->mesh->write_binary($output_file);
|
||||
$self->statusbar->SetStatusText("STL file exported to $output_file");
|
||||
}
|
||||
|
||||
|
@ -1654,7 +1654,7 @@ sub export_amf {
|
|||
return if !@{$self->{objects}};
|
||||
|
||||
my $output_file = $self->_get_export_file('AMF') or return;
|
||||
$self->{model}->store_amf(Slic3r::encode_path($output_file));
|
||||
$self->{model}->store_amf($output_file);
|
||||
$self->statusbar->SetStatusText("AMF file exported to $output_file");
|
||||
}
|
||||
|
||||
|
@ -1674,7 +1674,7 @@ sub _get_export_file {
|
|||
$dlg->Destroy;
|
||||
return undef;
|
||||
}
|
||||
$output_file = Slic3r::decode_path($dlg->GetPath);
|
||||
$output_file = $dlg->GetPath;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
return $output_file;
|
||||
|
|
|
@ -112,8 +112,9 @@ sub new {
|
|||
my $res = Wx::MessageDialog->new($self, "Are you sure you want to delete the selected preset?", 'Delete Preset', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION)->ShowModal;
|
||||
return unless $res == wxID_YES;
|
||||
# Delete the file.
|
||||
my $path = Slic3r::encode_path($self->{presets}[$i]->file);
|
||||
if (-e $path && ! unlink $path) {
|
||||
my $path = $self->{presets}[$i]->file;
|
||||
my $enc_path = Slic3r::encode_path($path);
|
||||
if (-e $enc_path && ! unlink $enc_path) {
|
||||
# Cannot delete the file, therefore the item will not be removed from the selection.
|
||||
Slic3r::GUI::show_error($self, "Cannot delete file $path : $!");
|
||||
return;
|
||||
|
@ -255,7 +256,7 @@ sub select_preset {
|
|||
sub select_preset_by_name {
|
||||
my ($self, $name) = @_;
|
||||
|
||||
$name = Unicode::Normalize::NFC($name);
|
||||
$name = Slic3r::normalize_utf8_nfc($name);
|
||||
$self->select_preset(first { $self->{presets}[$_]->name eq $name } 0 .. $#{$self->{presets}});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue