From 65d2e8f2994a8df0cd007effd6a7a87e5c181580 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 6 Jun 2023 17:22:46 +0200 Subject: [PATCH] Fix for #10745 - Using a star (*) in a preset name makes it unusable --- src/slic3r/GUI/PhysicalPrinterDialog.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index f7b632579..c54cda120 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -116,7 +116,7 @@ void PresetForPrinter::update_full_printer_name() wxString printer_name = m_parent->get_printer_name(); wxString preset_name = m_presets_list->GetString(m_presets_list->GetSelection()); - m_full_printer_name->SetLabelText(printer_name + " * " + preset_name); + m_full_printer_name->SetLabelText(printer_name + from_u8(PhysicalPrinter::separator()) + preset_name); } std::string PresetForPrinter::get_preset_name() @@ -654,6 +654,24 @@ wxString PhysicalPrinterDialog::get_printer_name() void PhysicalPrinterDialog::update_full_printer_names() { + // check input symbols for usability + + const char* unusable_symbols = "<>[]:/\\|?*\""; + + wxString printer_name = m_printer_name->GetValue(); + for (size_t i = 0; i < std::strlen(unusable_symbols); i++) { + size_t pos = printer_name.find_first_of(unusable_symbols[i]); + if (pos != std::string::npos) { + wxString str = printer_name.SubString(pos, 1); + printer_name.Remove(pos, 1); + InfoDialog(this, format_wxstr("%1%: \"%2%\" ", _L("Unexpected character"), str), + _L("The following characters are not allowed in the name") + ": " + unusable_symbols).ShowModal(); + m_printer_name->SetValue(printer_name); + m_printer_name->SetInsertionPointEnd(); + return; + } + } + for (PresetForPrinter* preset : m_presets) preset->update_full_printer_name();