diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index e5ea7b5c2..3d63a248f 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -439,8 +439,14 @@ sub update_presets { my $self = shift; my ($group, $presets, $selected, $is_dirty) = @_; - foreach my $choice (@{ $self->{preset_choosers}{$group} }) { - my $sel = $choice->GetSelection; + my @choosers = @{ $self->{preset_choosers}{$group} }; + foreach my $choice (@choosers) { + if ($group eq 'filament' && @choosers > 1) { + # if we have more than one filament chooser, keep our selection + # instead of importing the one from the tab + $selected = $choice->GetSelection; + $is_dirty = 0; + } $choice->Clear; foreach my $preset (@$presets) { my $bitmap; @@ -464,14 +470,15 @@ sub update_presets { $choice->AppendString($preset->name, $bitmap); } - if ($sel <= $#$presets) { - $choice->SetSelection($sel); + if ($selected <= $#$presets) { if ($is_dirty) { - $choice->SetString($sel, $choice->GetString($sel) . " (modified)"); + $choice->SetString($selected, $choice->GetString($selected) . " (modified)"); } + # call SetSelection() only after SetString() otherwise the new string + # won't be picked up as the visible string + $choice->SetSelection($selected); } } - $self->{preset_choosers}{$group}[0]->SetSelection($selected); } sub filament_presets { diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 0aed46ca3..88d7db8ba 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -229,6 +229,10 @@ sub on_select_preset { 'Unsaved Changes', wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION); if ($confirm->ShowModal == wxID_NO) { $self->{presets_choice}->SetSelection($self->current_preset); + + # trigger the on_presets_changed event so that we also restore the previous value + # in the plater selector + $self->_on_presets_changed; return; } }