From 624e16b7e22c6a28e93fe11da1b414887538ade0 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 10 Aug 2012 16:05:16 +0200 Subject: [PATCH] Unexpected results splitting objects with threaded perls. #610 --- lib/Slic3r/GUI/Plater.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 1c141fbf6..ee7e53690 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -323,10 +323,16 @@ sub object_loaded { sub remove { my $self = shift; + my ($obj_idx) = @_; - foreach my $pobj (@{$self->{selected_objects}}) { - my ($obj_idx, $copy_idx) = ($pobj->[0], $pobj->[1]); - $self->{print}->copies->[$obj_idx][$copy_idx] = undef; + if (defined $obj_idx) { + $self->{print}->copies->[$obj_idx][$_] = undef + for 0 .. $#{ $self->{print}->copies->[$obj_idx] }; + } else { + foreach my $pobj (@{$self->{selected_objects}}) { + my ($obj_idx, $copy_idx) = ($pobj->[0], $pobj->[1]); + $self->{print}->copies->[$obj_idx][$copy_idx] = undef; + } } my @objects_to_remove = (); @@ -476,9 +482,15 @@ sub split_object { my @new_meshes = $mesh->split_mesh; if (@new_meshes == 1) { - Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be splitted because it contained already a single part."); + Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be splitted because it already contains a single part."); return; } + + # remove the original object before spawning the object_loaded event, otherwise + # we'll pass the wrong $obj_idx to it (which won't be recognized after the + # thumbnail thread returns) + $self->remove($obj_idx); + foreach my $mesh (@new_meshes) { my $object = $self->{print}->add_object_from_mesh($mesh); $object->input_file($current_object->input_file); @@ -487,8 +499,6 @@ sub split_object { $self->object_loaded($new_obj_idx, no_arrange => 1); } - $self->{list}->Select($obj_idx, 1); - $self->remove; $self->arrange; }