move the main reload to after the dialog

This commit is contained in:
Michael Kirsch 2019-07-10 22:30:24 +02:00 committed by Joseph Lenox
parent 587629ac80
commit 29d3e46736

View File

@ -2536,27 +2536,18 @@ sub export_stl {
sub reload_from_disk { sub reload_from_disk {
my ($self) = @_; my ($self) = @_;
my ($obj_idx, $object) = $self->selected_object; my ($obj_idx, $org_obj) = $self->selected_object;
return if !defined $obj_idx; return if !defined $obj_idx;
if (!$object->input_file) { if (!$org_obj->input_file) {
Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be reloaded because it isn't referenced to its input file any more. This is the case after performing operations like cut or split."); Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be reloaded because it isn't referenced to its input file any more. This is the case after performing operations like cut or split.");
return; return;
} }
if (!-e $object->input_file) { if (!-e $org_obj->input_file) {
Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be reloaded because the file doesn't exist anymore on the disk."); Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be reloaded because the file doesn't exist anymore on the disk.");
return; return;
} }
# Only reload the selected object and not all objects from the input file.
my @new_obj_idx = $self->load_file($object->input_file, $object->input_file_obj_idx);
if (!@new_obj_idx) {
Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be reloaded because the new file doesn't contain the object.");
return;
}
my $org_obj = $self->{model}->objects->[$obj_idx];
# check if the object is dependant of more than one file # check if the object is dependant of more than one file
my $org_obj_has_modifiers=0; my $org_obj_has_modifiers=0;
for my $i (0..($org_obj->volumes_count-1)) { for my $i (0..($org_obj->volumes_count-1)) {
@ -2573,7 +2564,6 @@ sub reload_from_disk {
my $dlg = Slic3r::GUI::ReloadDialog->new(undef,$reload_behavior); my $dlg = Slic3r::GUI::ReloadDialog->new(undef,$reload_behavior);
my $res = $dlg->ShowModal; my $res = $dlg->ShowModal;
if ($res==wxID_CANCEL) { if ($res==wxID_CANCEL) {
$self->remove($_) for @new_obj_idx;
$dlg->Destroy; $dlg->Destroy;
return; return;
} }
@ -2591,6 +2581,13 @@ sub reload_from_disk {
$dlg->Destroy; $dlg->Destroy;
} }
# Only reload the selected object and not all objects from the input file.
my @new_obj_idx = $self->load_file($org_obj->input_file, $org_obj->input_file_obj_idx);
if (!@new_obj_idx) {
Slic3r::GUI::warning_catcher($self)->("The selected object couldn't be reloaded because the new file doesn't contain the object.");
return;
}
my $volume_unmatched=0; my $volume_unmatched=0;
foreach my $new_obj_idx (@new_obj_idx) { foreach my $new_obj_idx (@new_obj_idx) {