From 7589e4ebfce0b07a83d428c3fdb5191d49182c3d Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 3 Mar 2020 14:52:16 +0100 Subject: [PATCH] Fixed some more warnings --- src/libslic3r/CustomGCode.cpp | 3 ++- src/libslic3r/Fill/FillBase.cpp | 4 ++-- src/libslic3r/Format/3mf.cpp | 2 +- src/libslic3r/GCode.cpp | 4 ++-- src/libslic3r/GCode/Analyzer.cpp | 4 ++-- src/libslic3r/GCode/Analyzer.hpp | 2 +- src/libslic3r/Print.cpp | 2 +- src/slic3r/GUI/AppConfig.cpp | 2 +- src/slic3r/GUI/ConfigWizard.cpp | 2 +- src/slic3r/GUI/GLCanvas3D.cpp | 2 +- src/slic3r/GUI/GUI_ObjectList.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 2 +- src/slic3r/GUI/Preset.cpp | 2 +- src/slic3r/GUI/PresetBundle.cpp | 4 ++-- src/slic3r/Utils/FlashAir.cpp | 2 -- src/slic3r/Utils/PresetUpdater.cpp | 4 ++-- 16 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/libslic3r/CustomGCode.cpp b/src/libslic3r/CustomGCode.cpp index 7c505c9789..824bcdd93c 100644 --- a/src/libslic3r/CustomGCode.cpp +++ b/src/libslic3r/CustomGCode.cpp @@ -62,7 +62,8 @@ std::vector> custom_tool_changes(const Info& cus for (const Item& custom_gcode : custom_gcode_per_print_z.gcodes) if (custom_gcode.gcode == ToolChangeCode) { // If extruder count in PrinterSettings was changed, use default (0) extruder for extruders, more than num_extruders - custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast(custom_gcode.extruder > num_extruders ? 1 : custom_gcode.extruder)); + assert(custom_gcode.extruder >= 0); + custom_tool_changes.emplace_back(custom_gcode.print_z, static_cast(size_t(custom_gcode.extruder) > num_extruders ? 1 : custom_gcode.extruder)); } return custom_tool_changes; } diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index b8a83c57ee..3b200769cf 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -674,7 +674,7 @@ static inline double segment_point_distance_squared(const Vec2d &p1a, const Vec2 if (l2 < EPSILON) // p1a == p1b return (p2 - p1a).squaredNorm(); - return segment_point_distance_squared(p1a, p1b, v, v.squaredNorm(), p2); + return segment_point_distance_squared(p1a, p1b, v, v.squaredNorm(), p2); } // Distance to the closest point of line. @@ -692,7 +692,7 @@ static inline double min_distance_of_segments(const Vec2d &p1a, const Vec2d &p1b // p2a == p2b: Return distance of p2a from the (p1a, p1b) segment. return segment_point_distance_squared(p1a, p1b, v1, l1_2, p2a); - return std::min( + return std::min( std::min(segment_point_distance_squared(p1a, p1b, v1, l1_2, p2a), segment_point_distance_squared(p1a, p1b, v1, l1_2, p2b)), std::min(segment_point_distance_squared(p2a, p2b, v2, l2_2, p1a), segment_point_distance_squared(p2a, p2b, v2, l2_2, p1b))); } diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index efeb237003..462dcf27b8 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1722,7 +1722,7 @@ namespace Slic3r { } // Added because of github #3435, currently not used by PrusaSlicer - int instances_count_id = get_attribute_value_int(attributes, num_attributes, INSTANCESCOUNT_ATTR); + // int instances_count_id = get_attribute_value_int(attributes, num_attributes, INSTANCESCOUNT_ATTR); m_objects_metadata.insert(IdToMetadataMap::value_type(object_id, ObjectMetadata())); m_curr_config.object_id = object_id; diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 899b35cc3f..49a49a85e9 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1749,7 +1749,6 @@ std::vector GCode::sort_print_object_instances( std::sort(sorted.begin(), sorted.end()); if (! sorted.empty()) { - const Print &print = *sorted.front().first->print(); out.reserve(sorted.size()); for (const PrintInstance *instance : *ordering) { const PrintObject &print_object = *instance->print_object; @@ -1795,13 +1794,14 @@ namespace ProcessLayer // we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count if (color_change || tool_change) { + assert(m600_extruder_before_layer >= 0); // Color Change or Tool Change as Color Change. // add tag for analyzer gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_extruder_before_layer) + "\n"; // add tag for time estimator gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n"; - if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != m600_extruder_before_layer + if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != (unsigned)m600_extruder_before_layer // && !MMU1 ) { //! FIXME_in_fw show message during print pause diff --git a/src/libslic3r/GCode/Analyzer.cpp b/src/libslic3r/GCode/Analyzer.cpp index ec5de71b11..4098e66efc 100644 --- a/src/libslic3r/GCode/Analyzer.cpp +++ b/src/libslic3r/GCode/Analyzer.cpp @@ -644,7 +644,7 @@ bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line) if (pos != comment.npos) { pos = comment.find_last_of(",T"); - int extruder = pos == comment.npos ? 0 : std::atoi(comment.substr(pos + 1, comment.npos).c_str()); + unsigned extruder = pos == comment.npos ? 0 : std::stoi(comment.substr(pos + 1, comment.npos)); _process_color_change_tag(extruder); return true; } @@ -702,7 +702,7 @@ void GCodeAnalyzer::_process_height_tag(const std::string& comment, size_t pos) _set_height((float)::strtod(comment.substr(pos + Height_Tag.length()).c_str(), nullptr)); } -void GCodeAnalyzer::_process_color_change_tag(int extruder) +void GCodeAnalyzer::_process_color_change_tag(unsigned extruder) { m_extruder_color[extruder] = m_extruders_count + m_state.cp_color_counter; // color_change position in list of color for preview m_state.cp_color_counter++; diff --git a/src/libslic3r/GCode/Analyzer.hpp b/src/libslic3r/GCode/Analyzer.hpp index 781c3f265f..cd5654a745 100644 --- a/src/libslic3r/GCode/Analyzer.hpp +++ b/src/libslic3r/GCode/Analyzer.hpp @@ -220,7 +220,7 @@ private: void _process_height_tag(const std::string& comment, size_t pos); // Processes color change tag - void _process_color_change_tag(int extruder); + void _process_color_change_tag(unsigned extruder); // Processes pause print and custom gcode tag void _process_pause_print_or_custom_code_tag(); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index b4a2a1b3ea..5cdcbd2f8b 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -1936,7 +1936,7 @@ void Print::_make_brim() // Find all pieces that the initial loop was split into. size_t j = i + 1; for (; j < loops_trimmed_order.size() && loops_trimmed_order[i].second == loops_trimmed_order[j].second; ++ j) ; - const ClipperLib_Z::Path &first_path = *loops_trimmed_order[i].first; + const ClipperLib_Z::Path &first_path = *loops_trimmed_order[i].first; if (i + 1 == j && first_path.size() > 3 && first_path.front().X == first_path.back().X && first_path.front().Y == first_path.back().Y) { auto *loop = new ExtrusionLoop(); m_brim.entities.emplace_back(loop); diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp index 0a3d080c38..90bf337cfe 100644 --- a/src/slic3r/GUI/AppConfig.cpp +++ b/src/slic3r/GUI/AppConfig.cpp @@ -72,7 +72,7 @@ void AppConfig::set_defaults() if (get("remember_output_path").empty()) set("remember_output_path", "1"); - if (get("remember_output_path_removable").empty()) + if (get("remember_output_path_removable").empty()) set("remember_output_path_removable", "1"); if (get("use_custom_toolbar_size").empty()) diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 0e034b33b1..1f35d941d6 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -1726,7 +1726,7 @@ bool ConfigWizard::priv::on_bnt_finish() page_sla_materials->reload_presets(); // theres no need to check that filament is selected if we have only custom printer - if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true; + if (custom_printer_selected && !any_fff_selected && !any_sla_selected) return true; // check, that there is selected at least one filament/material return check_materials_in_config(T_ANY); } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index f9281434de..d3b83057e2 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1298,7 +1298,7 @@ void GLCanvas3D::Labels::render(const std::vector& sorted_ // updates print order strings if (sorted_instances.size() > 1) { - for (int i = 0; i < sorted_instances.size(); ++i) { + for (size_t i = 0; i < sorted_instances.size(); ++i) { size_t id = sorted_instances[i]->id().id; std::vector::iterator it = std::find_if(owners.begin(), owners.end(), [id](const Owner& owner) { return owner.model_instance_id == id; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index f315192517..afcf62ae15 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1543,7 +1543,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_) // If there are selected more then one instance but not all of them // don't add settings menu items const Selection& selection = scene_selection(); - if (selection.is_multiple_full_instance() && !selection.is_single_full_object() || + if ((selection.is_multiple_full_instance() && !selection.is_single_full_object()) || selection.is_multiple_volume() || selection.is_mixed() ) // more than one volume(part) is selected on the scene return nullptr; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index ed400bab86..7432f66336 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3611,7 +3611,7 @@ void Plater::priv::on_process_completed(wxCommandEvent &evt) else if (wxGetApp().get_mode() == comSimple) show_action_buttons(false); - if(!canceled && RemovableDriveManager::get_instance().get_is_writing()) + if(!canceled && RemovableDriveManager::get_instance().get_is_writing()) { RemovableDriveManager::get_instance().set_is_writing(false); show_action_buttons(false); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 833951afe8..e73133fdff 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -1012,7 +1012,7 @@ const std::string& PresetCollection::get_preset_name_by_alias(const std::string& it != m_map_alias_to_profile_name.end() && it->first == alias; ++ it) if (auto it_preset = this->find_preset_internal(it->second); it_preset != m_presets.end() && it_preset->name == it->second && - it_preset->is_visible && (it_preset->is_compatible || (it_preset - m_presets.begin()) == m_idx_selected)) + it_preset->is_visible && (it_preset->is_compatible || size_t(it_preset - m_presets.begin()) == m_idx_selected)) return it_preset->name; return alias; } diff --git a/src/slic3r/GUI/PresetBundle.cpp b/src/slic3r/GUI/PresetBundle.cpp index 3e8e994a3e..e36c85d685 100644 --- a/src/slic3r/GUI/PresetBundle.cpp +++ b/src/slic3r/GUI/PresetBundle.cpp @@ -1316,7 +1316,7 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla // Derive the profile logical name aka alias from the preset name if the alias was not stated explicitely. if (alias_name.empty()) { - int end_pos = preset_name.find_first_of("@"); + size_t end_pos = preset_name.find_first_of("@"); if (end_pos != std::string::npos) { alias_name = preset_name.substr(0, end_pos); if (renamed_from.empty()) @@ -1717,7 +1717,7 @@ void PresetBundle::update_plater_filament_ui(unsigned int idx_extruder, GUI::Pre if (selected_preset_item == INT_MAX) selected_preset_item = ui->GetCount() - 1; - ui->SetSelection(selected_preset_item); + ui->SetSelection(selected_preset_item); ui->SetToolTip(tooltip.IsEmpty() ? ui->GetString(selected_preset_item) : tooltip); ui->check_selection(); ui->Thaw(); diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index c033bd843a..c99a404ca4 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -182,8 +182,6 @@ std::string FlashAir::timestamp_str() const auto t = std::time(nullptr); auto tm = *std::localtime(&t); - const char *name = get_name(); - unsigned long fattime = ((tm.tm_year - 80) << 25) | ((tm.tm_mon + 1) << 21) | (tm.tm_mday << 16) | diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index a28937e153..4da5f0f527 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -526,8 +526,8 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version existing_idx.load(bundle_path_idx); // Find a recommended config bundle version for the slic3r version last executed. This makes sure that a config bundle update will not be missed // when upgrading an application. On the other side, the user will be bugged every time he will switch between slic3r versions. - const auto existing_recommended = existing_idx.recommended(old_slic3r_version); - /*if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) { + /*const auto existing_recommended = existing_idx.recommended(old_slic3r_version); + if (existing_recommended != existing_idx.end() && recommended->config_version == existing_recommended->config_version) { // The user has already seen (and presumably rejected) this update BOOST_LOG_TRIVIAL(info) << boost::format("Downloaded index for `%1%` is the same as installed one, not offering an update.") % idx.vendor(); continue;