More fixes for Unicode filenames support on Windows and OS X
This commit is contained in:
parent
7b65a35519
commit
56b993bb89
1
Build.PL
1
Build.PL
@ -22,6 +22,7 @@ my %prereqs = qw(
|
|||||||
IO::Scalar 0
|
IO::Scalar 0
|
||||||
threads 1.96
|
threads 1.96
|
||||||
Time::HiRes 0
|
Time::HiRes 0
|
||||||
|
Unicode::Normalize 0
|
||||||
);
|
);
|
||||||
my %recommends = qw(
|
my %recommends = qw(
|
||||||
Class::XSAccessor 0
|
Class::XSAccessor 0
|
||||||
|
@ -71,6 +71,7 @@ use Slic3r::Print::SupportMaterial;
|
|||||||
use Slic3r::Surface;
|
use Slic3r::Surface;
|
||||||
our $build = eval "use Slic3r::Build; 1";
|
our $build = eval "use Slic3r::Build; 1";
|
||||||
use Thread::Semaphore;
|
use Thread::Semaphore;
|
||||||
|
use Unicode::Normalize;
|
||||||
|
|
||||||
use constant SCALING_FACTOR => 0.000001;
|
use constant SCALING_FACTOR => 0.000001;
|
||||||
use constant RESOLUTION => 0.0125;
|
use constant RESOLUTION => 0.0125;
|
||||||
@ -261,7 +262,13 @@ sub resume_all_threads {
|
|||||||
sub encode_path {
|
sub encode_path {
|
||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
|
||||||
utf8::downgrade($path) if $^O eq 'MSWin32';
|
$path = Unicode::Normalize::NFC($path);
|
||||||
|
if ($^O eq 'MSWin32') {
|
||||||
|
utf8::downgrade($path);
|
||||||
|
} else {
|
||||||
|
utf8::encode($path);
|
||||||
|
}
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +280,12 @@ sub decode_path {
|
|||||||
} else {
|
} else {
|
||||||
utf8::decode($path);
|
utf8::decode($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The filesystem might force a normalization form (like HFS+ does) so
|
||||||
|
# if we rely on the filename being comparable after the open() + readdir()
|
||||||
|
# roundtrip (like when creating and then selecting a preset), we need to
|
||||||
|
# restore our normalization form.
|
||||||
|
$path = Unicode::Normalize::NFC($path);
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,8 @@ sub select_preset {
|
|||||||
|
|
||||||
sub select_preset_by_name {
|
sub select_preset_by_name {
|
||||||
my ($self, $name) = @_;
|
my ($self, $name) = @_;
|
||||||
|
|
||||||
|
$name = Unicode::Normalize::NFC($name);
|
||||||
$self->select_preset(first { $self->{presets}[$_]->name eq $name } 0 .. $#{$self->{presets}});
|
$self->select_preset(first { $self->{presets}[$_]->name eq $name } 0 .. $#{$self->{presets}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1462,7 +1464,7 @@ sub config {
|
|||||||
if ($self->default) {
|
if ($self->default) {
|
||||||
return Slic3r::Config->new_from_defaults(@$keys);
|
return Slic3r::Config->new_from_defaults(@$keys);
|
||||||
} else {
|
} else {
|
||||||
if (!-e $self->file) {
|
if (!-e Slic3r::encode_path($self->file)) {
|
||||||
Slic3r::GUI::show_error(undef, "The selected preset does not exist anymore (" . $self->file . ").");
|
Slic3r::GUI::show_error(undef, "The selected preset does not exist anymore (" . $self->file . ").");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user