Bugfix: object disappeared from 2D plater when reloaded from disk. #3634

This commit is contained in:
Alessandro Ranellucci 2016-12-22 12:13:28 +01:00
parent da0f4c4e01
commit 85bf2ed7ae

View File

@ -1434,10 +1434,10 @@ sub reload_from_disk {
return if !$model_object->input_file
|| !-e $model_object->input_file;
my @obj_idx = $self->load_file($model_object->input_file);
return if !@obj_idx;
my @new_obj_idx = $self->load_file($model_object->input_file);
return if !@new_obj_idx;
foreach my $new_obj_idx (@obj_idx) {
foreach my $new_obj_idx (@new_obj_idx) {
my $o = $self->{model}->objects->[$new_obj_idx];
$o->clear_instances;
$o->add_instance($_) for @{$model_object->instances};
@ -1450,6 +1450,12 @@ sub reload_from_disk {
}
$self->remove($obj_idx);
# Trigger thumbnail generation again, because the remove() method altered
# object indexes before background thumbnail generation called its completion
# event, so the on_thumbnail_made callback is called with the wrong $obj_idx.
# When porting to C++ we'll probably have cleaner ways to do this.
$self->make_thumbnail($_-1) for @new_obj_idx;
}
sub export_object_stl {