From 85bf2ed7aed3f70f7db755dd075940d33ba50cf9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 22 Dec 2016 12:13:28 +0100 Subject: [PATCH] Bugfix: object disappeared from 2D plater when reloaded from disk. #3634 --- lib/Slic3r/GUI/Plater.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4474550f58..9e61630fb2 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -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 {