diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index fd1af58b0..c58af979f 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -32,6 +32,11 @@ sub clone { Storable::dclone($_[0]) } +sub threadsafe_clone { + my $self = shift; + return (ref $self)->new(map $_->threadsafe_clone, @$self); +} + sub contour { my $self = shift; return $self->[0]; @@ -303,7 +308,7 @@ has 'expolygons' => (is => 'ro', default => sub { [] }); sub clone { my $self = shift; return (ref $self)->new( - expolygons => [ map $_->clone, @{$self->expolygons} ], + expolygons => [ map $_->threadsafe_clone, @{$self->expolygons} ], ); } diff --git a/lib/Slic3r/Point.pm b/lib/Slic3r/Point.pm index 233f60f34..4e86995e1 100644 --- a/lib/Slic3r/Point.pm +++ b/lib/Slic3r/Point.pm @@ -24,6 +24,11 @@ sub clone { Storable::dclone($_[0]) } +sub threadsafe_clone { + my $self = shift; + return (ref $self)->new(@$self); +} + sub coincides_with { my $self = shift; my ($point) = @_; diff --git a/lib/Slic3r/Polyline.pm b/lib/Slic3r/Polyline.pm index f2a9cbd7f..fd4bd571f 100644 --- a/lib/Slic3r/Polyline.pm +++ b/lib/Slic3r/Polyline.pm @@ -22,6 +22,11 @@ sub clone { Storable::dclone($_[0]) } +sub threadsafe_clone { + my $self = shift; + return (ref $self)->new(map $_->threadsafe_clone, @$self); +} + sub serialize { my $self = shift; return pack 'l*', map @$_, @$self;