From 67f3e9962b285a5600cada5a70594d8929ef9f18 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 23 Mar 2014 21:40:45 +0100 Subject: [PATCH] Prevent user from saving a preset with the "- default -" name. #1717 --- lib/Slic3r/Config.pm | 2 +- lib/Slic3r/GUI/Tab.pm | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 5fba7b392..3655a91a7 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -119,7 +119,7 @@ sub _handle_legacy { if ($opt_key eq 'gcode_flavor' && $value eq 'makerbot') { $value = 'makerware'; } - if ($opt_key eq 'fill_density' && $value <= 1) { + if ($opt_key eq 'fill_density' && defined($value) && $value <= 1) { # fill_density was turned into a percent value $value *= 100; $value = "$value"; # force update of the PV value, workaround for bug https://rt.cpan.org/Ticket/Display.html?id=94110 diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 8a0426117..15b98b518 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -893,8 +893,10 @@ sub new { my ($parent, %params) = @_; my $self = $class->SUPER::new($parent, -1, "Save preset", wxDefaultPosition, wxDefaultSize); + my @values = grep $_ ne '- default -', @{$params{values}}; + my $text = Wx::StaticText->new($self, -1, "Save " . lc($params{title}) . " as:", wxDefaultPosition, wxDefaultSize); - $self->{combo} = Wx::ComboBox->new($self, -1, $params{default}, wxDefaultPosition, wxDefaultSize, $params{values}, + $self->{combo} = Wx::ComboBox->new($self, -1, $params{default}, wxDefaultPosition, wxDefaultSize, \@values, wxTE_PROCESS_ENTER); my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL); @@ -916,10 +918,12 @@ sub accept { my ($self, $event) = @_; if (($self->{chosen_name} = $self->{combo}->GetValue)) { - if ($self->{chosen_name} =~ /^[^<>:\/\\|?*\"]+$/i) { - $self->EndModal(wxID_OK); - } else { + if ($self->{chosen_name} !~ /^[^<>:\/\\|?*\"]+$/i) { Slic3r::GUI::show_error($self, "The supplied name is not valid; the following characters are not allowed: <>:/\|?*\""); + } elsif ($self->{chosen_name} eq '- default -') { + Slic3r::GUI::show_error($self, "The supplied name is not available."); + } else { + $self->EndModal(wxID_OK); } } }