From dddbe64b866e10a7c88645faadb77a2508341d1e Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 19 Mar 2017 00:31:14 -0500 Subject: [PATCH] Restrict file types for model exports to what we are permitting (UX fix). Changed extension from .amf.xml -> .amf (common usage) Fixes #3774 --- lib/Slic3r/GUI.pm | 2 ++ lib/Slic3r/GUI/Plater.pm | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 7d2f7f26b3..2459ef9c5c 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -53,6 +53,8 @@ use constant FILE_WILDCARDS => { svg => 'SVG files *.svg|*.svg;*.SVG', }; use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf)}; +use constant STL_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(stl)}; +use constant AMF_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(amf)}; our $datadir; # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden. diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 7f6c215983..c72350def0 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1570,14 +1570,21 @@ sub _get_export_file { my $self = shift; my ($format) = @_; - my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml'; + my $suffix = $format eq 'STL' ? '.stl' : '.amf'; my $output_file = $main::opt{output}; { $output_file = $self->{print}->output_filepath($output_file // ''); $output_file =~ s/\.gcode$/$suffix/i; - my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file), - basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + my $dlg; + $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file), + basename($output_file), &Slic3r::GUI::STL_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT) + if $format eq 'STL'; + + $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file), + basename($output_file), &Slic3r::GUI::AMF_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT) + if $format eq 'AMF'; + if ($dlg->ShowModal != wxID_OK) { $dlg->Destroy; return undef;