diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 312aeed3ad..cbccbe99d3 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1158,8 +1158,8 @@ bool TextCtrl::value_was_changed() case coPoints: if (m_opt_idx < 0) { return boost::any_cast>(m_value) != boost::any_cast>(val); - } else if (boost::any_cast>(m_value).size() > m_opt_idx - && boost::any_cast>(val).size() > m_opt_idx) { + } else if (int(boost::any_cast>(m_value).size()) > m_opt_idx + && int(boost::any_cast>(val).size()) > m_opt_idx) { return boost::any_cast>(m_value)[m_opt_idx] != boost::any_cast>(val)[m_opt_idx]; } case coPoint: @@ -1363,7 +1363,7 @@ void CheckBox::Rescale(wxWindow* win) } #ifdef __WXGTK2__ if (wxToggleButton* chk = dynamic_cast(win)) - chk->Rescale(); + chk->Update(); #endif } @@ -1402,12 +1402,14 @@ void CheckBox::BUILD() { #ifdef __WXGTK2__ //gtk2 can't resize checkboxes, so we are using togglable buttons instead window->Bind(wxEVT_TOGGLEBUTTON, ([this](wxCommandEvent e) { - m_is_na_val = false; - if (static_cast(window)->GetValue()) - static_cast(window)->SetLabel("X"); - else - static_cast(window)->SetLabel(""); - on_change_field(); + if (wxToggleButton* chk = dynamic_cast(window)) { + m_is_na_val = false; + if (chk->GetValue()) + chk->SetLabel("X"); + else + chk->SetLabel(""); + on_change_field(); + } }), window->GetId()); #else window->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent e) { @@ -1870,18 +1872,19 @@ void Choice::set_selection() field->SetSelection(*opt); else field->SetValue(text_value); - } + } } void Choice::set_text_value(const std::string &value, bool change_event) //! Redundant? { m_disable_change_event = !change_event; choice_ctrl* field = dynamic_cast(window); - if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value()) + if (auto opt = m_opt.enum_def->value_to_index(value); opt.has_value()) { // This enum has a value field of the same content as text_value. Select it. field->SetSelection(*opt); - else + } else { field->SetValue(value); + } m_disable_change_event = false; } @@ -2011,19 +2014,20 @@ boost::any& Choice::get_value() else if (m_opt.gui_type == ConfigOptionDef::GUIType::f_enum_open || m_opt.gui_type == ConfigOptionDef::GUIType::i_enum_open) { // Open enum: The combo box item index returned by the field const int ret_enum = field->GetSelection(); - if (m_opt.enum_def->has_values() && (m_opt.type == coString || m_opt.type == coStrings) && ret_enum >=0 && ret_enum < m_opt.enum_def->values().size()) { + if (m_opt.enum_def->has_values() && (m_opt.type == coString || m_opt.type == coStrings) && ret_enum >=0 && ret_enum < int(m_opt.enum_def->values().size())) { m_value = m_opt.enum_def->value(ret_enum); } else if (ret_enum < 0 || !m_opt.enum_def->has_values() || m_opt.type == coStrings || - (into_u8(ret_str) != m_opt.enum_def->value(ret_enum) && ret_str != _(m_opt.enum_def->label(ret_enum)))) + (into_u8(ret_str) != m_opt.enum_def->value(ret_enum) && ret_str != _(m_opt.enum_def->label(ret_enum)))) { // modifies ret_string! get_value_by_opt_type(ret_str); - else if (m_opt.type == coFloatOrPercent) { + } else if (m_opt.type == coFloatOrPercent) { m_value = FloatOrPercent{string_to_double_decimal_point(m_opt.enum_def->value(ret_enum)), (m_opt.enum_def->value(ret_enum).find('%') != std::string::npos)}; - } else if (m_opt.type == coInt) + } else if (m_opt.type == coInt) { m_value = atoi(m_opt.enum_def->value(ret_enum).c_str()); - else + } else { m_value = string_to_double_decimal_point(m_opt.enum_def->value(ret_enum)); + } } else // modifies ret_string! @@ -2095,16 +2099,15 @@ void ColourPicker::BUILD() // Validate the color wxColour clr = wxTransparentColour; if (m_opt.type == coStrings) - clr = wxColour{wxString{ m_opt.get_default_value()->get_at(m_opt_idx) }}; + clr = wxColour{wxString{m_opt.get_default_value()->get_at(m_opt_idx)}}; if (m_opt.type == coString) - clr = wxColour{ wxString{ m_opt.get_default_value()->value } }; + clr = wxColour{wxString{m_opt.get_default_value()->value}}; if (m_opt.type == coInts) - clr = wxColour{ (unsigned long)m_opt.get_default_value()->get_at(m_opt_idx) }; + clr = wxColour{(unsigned long) m_opt.get_default_value()->get_at(m_opt_idx)}; if (m_opt.type == coInt) - clr = wxColour{ (unsigned long)m_opt.get_default_value()->value }; - if (!clr.IsOk()) { - clr = wxTransparentColour; - } + clr = wxColour{(unsigned long) m_opt.get_default_value()->value}; + if (!clr.IsOk()) + clr = wxTransparentColour; auto temp = new wxColourPickerCtrl(m_parent, wxID_ANY, clr, wxDefaultPosition, size); if (parent_is_custom_ctrl && m_opt.height < 0) @@ -2320,11 +2323,13 @@ void PointCtrl::BUILD() const wxSize field_size(4 * m_em_unit, -1); Vec2d default_pt; - if (m_opt.type == coPoint) + if (m_opt.type == coPoint) { default_pt = m_opt.get_default_value()->value; - else // coPoints + } else { // coPoints + assert(m_opt.type == coPoints); default_pt = m_opt.get_default_value()->get_at(0); - double val = default_pt(0); + } + double val = default_pt.x(); wxString X = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); val = default_pt(1); wxString Y = val - int(val) == 0 ? wxString::Format(_T("%i"), int(val)) : wxNumberFormatter::ToString(val, 2, wxNumberFormatter::Style_None); diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index e9a660c6e7..1ee5b28279 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -413,7 +413,7 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) try { if (view_params.exact) pattern = std::wregex(wsearch, std::regex_constants::icase); - } catch (std::regex_error reg_err) { + } catch (std::regex_error) { // Happens when std::wregex("]") or similar. => no result //TODO: add warning message 'wrong regexp' fail_pattern = true; } diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 0f07c16450..b30866415f 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -4778,6 +4778,11 @@ void Tab::transfer_options(const std::string &name_from, const std::string &name Preset* preset_from = m_presets->find_preset(name_from); Preset* preset_to = m_presets->find_preset(name_to); + + if (preset_from == nullptr || preset_to == nullptr){ + assert(false); + return; + } if (m_type == Preset::TYPE_PRINTER) { auto it = std::find(options.begin(), options.end(), "extruders_count"); diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 391b24db61..eaf877d928 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -1095,6 +1095,7 @@ wxString graph_to_string(const GraphData &graph) case GraphData::GraphType::SQUARE: str = _L("Square") + ":"; break; case GraphData::GraphType::LINEAR: str = _L("Linear") + ":"; break; case GraphData::GraphType::SPLINE: str = _L("Spline") + ":"; break; + default: assert(false); } for (const Vec2d &pt : graph.data()) { str += format_wxstr(" %1%,%2%", pt.x(), pt.y()); } return str; @@ -1119,17 +1120,18 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& case coInts: { if (is_nullable) { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return from_u8((boost::format("%1%") % values->get_at(opt_idx)).str()); - else + } else { return from_u8(values->serialize()); - } - else { + } + } else { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return from_u8((boost::format("%1%") % values->get_at(opt_idx)).str()); - else + } else { return from_u8(values->serialize()); + } } return _L("Undef"); } @@ -1138,17 +1140,19 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& case coBools: { if (is_nullable) { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return values->get_at(opt_idx) ? "true" : "false"; - else + } else { return from_u8(values->serialize()); + } } else { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return values->get_at(opt_idx) ? "true" : "false"; - else + } else { return from_u8(values->serialize()); + } } return _L("Undef"); } @@ -1157,17 +1161,18 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& case coPercents: { if (is_nullable) { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return from_u8((boost::format("%1%%%") % values->get_at(opt_idx)).str()); - else + } else { return from_u8(values->serialize()); - } - else { + } + } else { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return from_u8((boost::format("%1%%%") % values->get_at(opt_idx)).str()); - else + } else { return from_u8(values->serialize()); + } } return _L("Undef"); } @@ -1176,17 +1181,18 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& case coFloats: { if (is_nullable) { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return double_to_string(values->get_at(opt_idx), opt->precision); - else + } else { return from_u8(values->serialize()); - } - else { + } + } else { auto values = config.opt(opt_key); - if (opt_idx < values->size()) + if (opt_idx < values->size()) { return double_to_string(values->get_at(opt_idx), opt->precision); - else + } else { return from_u8(values->serialize()); + } } return _L("Undef"); } @@ -1202,27 +1208,33 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& const ConfigOptionStrings* strings = config.opt(opt_key); if (strings) { if (opt_key == "compatible_printers" || opt_key == "compatible_prints") { - if (strings->empty()) - return _L("All"); - for (size_t id = 0; id < strings->size(); id++) + if (strings->empty()) { + return _L("All"); + } + for (size_t id = 0; id < strings->size(); id++) { out += from_u8(strings->get_at(id)) + "\n"; + } out.RemoveLast(1); return out; } if (opt_key == "gcode_substitutions") { - if (!strings->empty()) - for (size_t id = 0; id < strings->size(); id += 4) + if (!strings->empty()) { + for (size_t id = 0; id < strings->size(); id += 4) { out += from_u8(strings->get_at(id)) + ";\t" + from_u8(strings->get_at(id + 1)) + ";\t" + from_u8(strings->get_at(id + 2)) + ";\t" + from_u8(strings->get_at(id + 3)) + ";\n"; + } + } return out; } - if (!strings->empty()) - if (opt_idx < strings->size()) + if (!strings->empty()) { + if (opt_idx < strings->size()) { return from_u8(strings->get_at(opt_idx)); - else + } else { return from_u8(strings->serialize()); + } + } } break; } @@ -1259,22 +1271,27 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& } const ConfigOptionPoints* opt_pts = config.opt(opt_key); - if (!opt_pts->empty()) - if (opt_idx < opt_pts->size()) - return from_u8((boost::format("[%1%]") % ConfigOptionPoint(opt_pts->get_at(opt_idx)).serialize()).str()); - else + if (!opt_pts->empty()) { + if (opt_idx < opt_pts->size()) { + return from_u8( + (boost::format("[%1%]") % ConfigOptionPoint(opt_pts->get_at(opt_idx)).serialize()).str()); + } else { return from_u8(opt_pts->serialize()); + } + } } case coGraph: { return graph_to_string(config.option(opt_key)->value); } case coGraphs: { const ConfigOptionGraphs* opt_graphs = config.opt(opt_key); - if (!opt_graphs->empty()) - if (opt_idx < opt_graphs->size()) + if (!opt_graphs->empty()) { + if (opt_idx < opt_graphs->size()) { return graph_to_string(opt_graphs->get_at(opt_idx)); - else + } else { return from_u8(opt_graphs->serialize()); + } + } } default: break; @@ -2154,6 +2171,7 @@ std::string DiffPresetDialog::get_left_preset_name(Preset::Type type) return Preset::remove_suffix_modified(get_selection(preset_combos.presets_left)); } } + return ""; } std::string DiffPresetDialog::get_right_preset_name(Preset::Type type) @@ -2163,6 +2181,7 @@ std::string DiffPresetDialog::get_right_preset_name(Preset::Type type) return Preset::remove_suffix_modified(get_selection(preset_combos.presets_right)); } } + return ""; } }