From dc4bdad84a3b342e105f247afb8edfc3a9304eff Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 29 Jan 2021 14:47:41 +0100 Subject: [PATCH] Fixed some more GCC warnings --- src/libslic3r/Fill/FillRectilinear.cpp | 5 +++-- src/libslic3r/PresetBundle.cpp | 7 +++---- src/libslic3r/ShortestPath.cpp | 9 ++++++--- src/slic3r/GUI/PresetComboBoxes.cpp | 2 +- tests/libslic3r/test_elephant_foot_compensation.cpp | 3 +++ tests/libslic3r/test_marchingsquares.cpp | 2 ++ 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/Fill/FillRectilinear.cpp b/src/libslic3r/Fill/FillRectilinear.cpp index 99d25b52a..d6e400837 100644 --- a/src/libslic3r/Fill/FillRectilinear.cpp +++ b/src/libslic3r/Fill/FillRectilinear.cpp @@ -2178,11 +2178,11 @@ static std::vector chain_monotonic_regions( float best_path_length = std::numeric_limits::max(); struct NextCandidate { - MonotonicRegion *region; + MonotonicRegion *region = nullptr; AntPath *link; AntPath *link_flipped; float probability; - bool dir; + bool dir = false; }; std::vector next_candidates; @@ -2317,6 +2317,7 @@ static std::vector chain_monotonic_regions( queue.pop_back(); } // Extend the path. + assert(next_candidate.region); MonotonicRegion *next_region = next_candidate.region; bool next_dir = next_candidate.dir; total_length += next_region->length(next_dir) + path_matrix(*path_end.region, path_end.flipped, *next_region, next_dir).length; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index c0f193f05..d9b1ed76e 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -800,10 +800,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool compatible_printers_condition = compatible_printers_condition_values[1]; compatible_prints_condition = compatible_prints_condition_values.front(); Preset *loaded = nullptr; - if (is_external) { - auto [aloaded, modified] = this->filaments.load_external_preset(name_or_path, name, old_filament_profile_names->values.front(), config); - loaded = aloaded; - } else { + if (is_external) + loaded = this->filaments.load_external_preset(name_or_path, name, old_filament_profile_names->values.front(), config).first; + else { // called from Config Wizard. loaded= &this->filaments.load_preset(this->filaments.path_from_name(name), name, config); loaded->save(); diff --git a/src/libslic3r/ShortestPath.cpp b/src/libslic3r/ShortestPath.cpp index daffcd5f2..facedec3f 100644 --- a/src/libslic3r/ShortestPath.cpp +++ b/src/libslic3r/ShortestPath.cpp @@ -1553,7 +1553,8 @@ static inline void reorder_by_two_exchanges_with_segment_flipping(std::vector::max(); size_t crossover2_pos_final = std::numeric_limits::max(); size_t crossover_flip_final = 0; - for (const auto& [longest_connection_length, longest_connection_idx] : connection_lengths) { + for (const std::pair& first_crossover_candidate : connection_lengths) { + size_t longest_connection_idx = first_crossover_candidate.second; connection_tried[longest_connection_idx] = true; // Find the second crossover connection with the lowest total chain cost. size_t crossover_pos_min = std::numeric_limits::max(); @@ -1628,7 +1629,8 @@ static inline void reorder_by_three_exchanges_with_segment_flipping(std::vector< size_t crossover2_pos_final = std::numeric_limits::max(); size_t crossover3_pos_final = std::numeric_limits::max(); size_t crossover_flip_final = 0; - for (const auto& [longest_connection_length, longest_connection_idx] : connection_lengths) { + for (const std::pair &first_crossover_candidate : connection_lengths) { + size_t longest_connection_idx = first_crossover_candidate.second; connection_tried[longest_connection_idx] = true; // Find the second crossover connection with the lowest total chain cost. double crossover_cost_min = connections.back().cost; @@ -1784,7 +1786,8 @@ static inline void reorder_by_three_exchanges_with_segment_flipping2(std::vector #else /* NDEBUG */ Matrixd segment_end_point_distance_matrix = Matrixd::Constant(4 * 4, 4 * 4, std::numeric_limits::max()); #endif /* NDEBUG */ - for (const auto& [longest_connection_length, longest_connection_idx] : connection_lengths) { + for (const std::pair &first_crossover_candidate : connection_lengths) { + size_t longest_connection_idx = first_crossover_candidate.second; connection_tried[longest_connection_idx] = true; // Find the second crossover connection with the lowest total chain cost. double crossover_cost_min = connections.back().cost; diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index ed8824a67..60bb9a5ae 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -201,7 +201,7 @@ void PresetComboBox::update_selection() if (!cell) return; - g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, NULL); + g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, (char*)NULL); // Only the list of cells must be freed, the renderer isn't ours to free g_list_free(cells); diff --git a/tests/libslic3r/test_elephant_foot_compensation.cpp b/tests/libslic3r/test_elephant_foot_compensation.cpp index a571e8d03..180f678c5 100644 --- a/tests/libslic3r/test_elephant_foot_compensation.cpp +++ b/tests/libslic3r/test_elephant_foot_compensation.cpp @@ -16,6 +16,7 @@ using namespace Slic3r; namespace Slic3r { ClipperLib::Path mittered_offset_path_scaled(const Points& contour, const std::vector& deltas, double miter_limit); +#if 0 static Points mittered_offset_path_scaled_points(const Points& contour, const std::vector& deltas, double miter_limit) { Points out; @@ -29,6 +30,7 @@ namespace Slic3r { } return out; } +#endif } static ExPolygon spirograph_gear_1mm() @@ -494,6 +496,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") { ExPolygon input = spirograph_gear_1mm().simplify(SCALED_EPSILON).front(); ExPolygon output; std::vector deltas(input.contour.points.size(), scale_(1.)); + // mittered_offset_path_scaled_points is commented out somewhere above output.contour.points = Slic3r::mittered_offset_path_scaled_points(input.contour.points, deltas, 2.); #ifdef TESTS_EXPORT_SVGS { diff --git a/tests/libslic3r/test_marchingsquares.cpp b/tests/libslic3r/test_marchingsquares.cpp index e9e016157..1a4b1fb72 100644 --- a/tests/libslic3r/test_marchingsquares.cpp +++ b/tests/libslic3r/test_marchingsquares.cpp @@ -326,7 +326,9 @@ static void recreate_object_from_rasters(const std::string &objname, float lh) { double disp_w = 120.96; double disp_h = 68.04; +#ifndef NDEBUG size_t cntr = 0; +#endif for (ExPolygons &layer : layers) { auto rst = create_raster(res, disp_w, disp_h);