diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index a98ef4593..57a8f7700 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -271,31 +271,35 @@ void PhysicalPrinterDialog::update_printers() wxArrayString printers; Field* rs = m_optgroup->get_field("printhost_port"); - if (!host->get_printers(printers)) { - std::vector slugs; + try { + if (!host->get_printers(printers)) { + std::vector slugs; - Choice* choice = dynamic_cast(rs); - choice->set_values(slugs); + Choice* choice = dynamic_cast(rs); + choice->set_values(slugs); - rs->disable(); - } else { - std::vector slugs; - for (int i = 0; i < printers.size(); i++) { - slugs.push_back(printers[i].ToStdString()); + rs->disable(); + } else { + std::vector slugs; + for (int i = 0; i < printers.size(); i++) { + slugs.push_back(printers[i].ToStdString()); + } + + Choice* choice = dynamic_cast(rs); + choice->set_values(slugs); + boost::any val = choice->get_value(); + boost::any any_string_type = std::string(""); + auto value_idx = std::find(slugs.begin(), slugs.end(), m_config->opt("printhost_port")->value); + if ((val.empty() || (any_string_type.type() == val.type() && boost::any_cast(val) == "")) && !slugs.empty() && value_idx == slugs.end()) { + change_opt_value(*m_config, "printhost_port", slugs[0]); + choice->set_value(slugs[0], false); + } else if (value_idx != slugs.end()) { + choice->set_value(m_config->option("printhost_port")->value, false); + } + rs->enable(); } - - Choice* choice = dynamic_cast(rs); - choice->set_values(slugs); - boost::any val = choice->get_value(); - boost::any any_string_type = std::string(""); - auto value_idx = std::find(slugs.begin(), slugs.end(), m_config->opt("printhost_port")->value); - if ((val.empty() || (any_string_type.type() == val.type() && boost::any_cast(val) == "")) && !slugs.empty() && value_idx == slugs.end()) { - change_opt_value(*m_config, "printhost_port", slugs[0]); - choice->set_value(slugs[0],false); - } else if(value_idx != slugs.end() ){ - choice->set_value(m_config->option("printhost_port")->value, false); - } - rs->enable(); + } catch (HostNetworkError error) { + show_error(this, error.what()); } } diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index c3c24c38e..7bae531ea 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -62,11 +62,14 @@ bool Repetier::test(wxString &msg) const std::stringstream ss(body); pt::ptree ptree; pt::read_json(ss, ptree); - - const auto text = ptree.get_optional("name"); - res = validate_version_text(text); - if (! res) { - msg = GUI::from_u8((boost::format(_u8L("Mismatched type of print host: %s")) % (text ? *text : "Repetier")).str()); + + res = ptree.get_optional("name").has_value(); + if (!res) + msg = GUI::from_u8((boost::format(_u8L("Can't process the repetier return message: missing field '%s'")) % ("name")).str()); + else { + res = ptree.get_optional("printers").has_value(); + if (!res) + msg = GUI::from_u8((boost::format(_u8L("Can't process the repetier return message: missing field '%s'")) % ("printers")).str()); } } catch (const std::exception &) {