Partial GUI compatibility with XS data

xsdata-boost
Alessandro Ranellucci 2013-07-07 18:43:04 +02:00
parent 8380ca812b
commit 5409c27852
4 changed files with 11 additions and 14 deletions

View File

@ -86,7 +86,14 @@ sub parallelize {
my $q = Thread::Queue->new;
$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) {
$params{collect_cb}->($th->join);

View File

@ -35,11 +35,6 @@ sub clone {
# no-op for legacy with ::XS
sub arrayref { $_[0] }
sub threadsafe_clone {
my $self = shift;
return (ref $self)->new(map $_->threadsafe_clone, @$self);
}
sub contour {
my $self = shift;
return $self->[0];
@ -314,7 +309,7 @@ has 'expolygons' => (is => 'ro', default => sub { [] });
sub clone {
my $self = shift;
return (ref $self)->new(
expolygons => [ map $_->threadsafe_clone, @{$self->expolygons} ],
expolygons => [ map $_->clone, @{$self->expolygons} ],
);
}

View File

@ -921,7 +921,7 @@ sub mouse_event {
$parent->selection_changed(0);
for my $preview (@{$parent->{object_previews}}) {
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->{list}->Select($obj_idx, 1);
$parent->selection_changed(1);
@ -951,7 +951,7 @@ sub mouse_event {
} elsif ($event->Moving) {
my $cursor = wxSTANDARD_CURSOR;
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);
last;
}

View File

@ -22,11 +22,6 @@ 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;