Partial GUI compatibility with XS data
This commit is contained in:
parent
8380ca812b
commit
5409c27852
4 changed files with 11 additions and 14 deletions
|
@ -86,7 +86,14 @@ sub parallelize {
|
||||||
my $q = Thread::Queue->new;
|
my $q = Thread::Queue->new;
|
||||||
$q->enqueue(@items, (map undef, 1..$Config->threads));
|
$q->enqueue(@items, (map undef, 1..$Config->threads));
|
||||||
|
|
||||||
my $thread_cb = sub { $params{thread_cb}->($q) };
|
my $thread_cb = sub {
|
||||||
|
# prevent destruction of shared objects
|
||||||
|
no warnings 'redefine';
|
||||||
|
*Slic3r::ExPolygon::XS::DESTROY = sub {};
|
||||||
|
|
||||||
|
return $params{thread_cb}->($q);
|
||||||
|
};
|
||||||
|
|
||||||
@_ = ();
|
@_ = ();
|
||||||
foreach my $th (map threads->create($thread_cb), 1..$Config->threads) {
|
foreach my $th (map threads->create($thread_cb), 1..$Config->threads) {
|
||||||
$params{collect_cb}->($th->join);
|
$params{collect_cb}->($th->join);
|
||||||
|
|
|
@ -35,11 +35,6 @@ sub clone {
|
||||||
# no-op for legacy with ::XS
|
# no-op for legacy with ::XS
|
||||||
sub arrayref { $_[0] }
|
sub arrayref { $_[0] }
|
||||||
|
|
||||||
sub threadsafe_clone {
|
|
||||||
my $self = shift;
|
|
||||||
return (ref $self)->new(map $_->threadsafe_clone, @$self);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub contour {
|
sub contour {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->[0];
|
return $self->[0];
|
||||||
|
@ -314,7 +309,7 @@ has 'expolygons' => (is => 'ro', default => sub { [] });
|
||||||
sub clone {
|
sub clone {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return (ref $self)->new(
|
return (ref $self)->new(
|
||||||
expolygons => [ map $_->threadsafe_clone, @{$self->expolygons} ],
|
expolygons => [ map $_->clone, @{$self->expolygons} ],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -921,7 +921,7 @@ sub mouse_event {
|
||||||
$parent->selection_changed(0);
|
$parent->selection_changed(0);
|
||||||
for my $preview (@{$parent->{object_previews}}) {
|
for my $preview (@{$parent->{object_previews}}) {
|
||||||
my ($obj_idx, $instance_idx, $thumbnail) = @$preview;
|
my ($obj_idx, $instance_idx, $thumbnail) = @$preview;
|
||||||
if (first { $_->contour->encloses_point($pos) } @{$thumbnail->expolygons}) {
|
if (defined first { $_->contour->encloses_point($pos) } @{$thumbnail->expolygons}) {
|
||||||
$parent->{selected_objects} = [ [$obj_idx, $instance_idx] ];
|
$parent->{selected_objects} = [ [$obj_idx, $instance_idx] ];
|
||||||
$parent->{list}->Select($obj_idx, 1);
|
$parent->{list}->Select($obj_idx, 1);
|
||||||
$parent->selection_changed(1);
|
$parent->selection_changed(1);
|
||||||
|
@ -951,7 +951,7 @@ sub mouse_event {
|
||||||
} elsif ($event->Moving) {
|
} elsif ($event->Moving) {
|
||||||
my $cursor = wxSTANDARD_CURSOR;
|
my $cursor = wxSTANDARD_CURSOR;
|
||||||
for my $preview (@{$parent->{object_previews}}) {
|
for my $preview (@{$parent->{object_previews}}) {
|
||||||
if (first { $_->contour->encloses_point($pos) } @{ $preview->[2]->expolygons }) {
|
if (defined first { $_->contour->encloses_point($pos) } @{ $preview->[2]->expolygons }) {
|
||||||
$cursor = Wx::Cursor->new(wxCURSOR_HAND);
|
$cursor = Wx::Cursor->new(wxCURSOR_HAND);
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,6 @@ sub clone {
|
||||||
Storable::dclone($_[0])
|
Storable::dclone($_[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
sub threadsafe_clone {
|
|
||||||
my $self = shift;
|
|
||||||
return (ref $self)->new(map $_->threadsafe_clone, @$self);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub serialize {
|
sub serialize {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return pack 'l*', map @$_, @$self;
|
return pack 'l*', map @$_, @$self;
|
||||||
|
|
Loading…
Reference in a new issue