From b5280fbed97404fd2ef75692102ff1f3963c58b3 Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Mon, 11 Jan 2021 10:23:56 +0100
Subject: [PATCH 1/3] Fixing GCC warnings 1

---
 src/libslic3r/EdgeGrid.cpp             |   4 +-
 src/libslic3r/EdgeGrid.hpp             |  16 ++-
 src/libslic3r/Fill/FillAdaptive.cpp    | 143 +++++++++++++------------
 src/libslic3r/Fill/FillAdaptive.hpp    |   4 +-
 src/libslic3r/Fill/FillBase.cpp        |  21 ++--
 src/libslic3r/Fill/FillRectilinear.cpp |  32 ++----
 src/libslic3r/GCode/GCodeProcessor.cpp |   7 +-
 src/libslic3r/LayerRegion.cpp          |   2 +-
 src/libslic3r/PresetBundle.cpp         |   7 --
 9 files changed, 107 insertions(+), 129 deletions(-)

diff --git a/src/libslic3r/EdgeGrid.cpp b/src/libslic3r/EdgeGrid.cpp
index e7307fda4..7bab590f7 100644
--- a/src/libslic3r/EdgeGrid.cpp
+++ b/src/libslic3r/EdgeGrid.cpp
@@ -1483,8 +1483,8 @@ bool EdgeGrid::Grid::has_intersecting_edges() const
 
 void EdgeGrid::save_png(const EdgeGrid::Grid &grid, const BoundingBox &bbox, coord_t resolution, const char *path, size_t scale)
 {
-	unsigned int w = (bbox.max(0) - bbox.min(0) + resolution - 1) / resolution;
-	unsigned int h = (bbox.max(1) - bbox.min(1) + resolution - 1) / resolution;
+    coord_t w = (bbox.max(0) - bbox.min(0) + resolution - 1) / resolution;
+    coord_t h = (bbox.max(1) - bbox.min(1) + resolution - 1) / resolution;
 
 	std::vector<uint8_t> pixels(w * h * 3, 0);
 
diff --git a/src/libslic3r/EdgeGrid.hpp b/src/libslic3r/EdgeGrid.hpp
index c3bc869d4..7b5e3905c 100644
--- a/src/libslic3r/EdgeGrid.hpp
+++ b/src/libslic3r/EdgeGrid.hpp
@@ -88,10 +88,10 @@ public:
 		assert(m_bbox.contains(p2));
 		p1 -= m_bbox.min;
 		p2 -= m_bbox.min;
-		assert(p1.x() >= 0 && p1.x() < m_cols * m_resolution);
-		assert(p1.y() >= 0 && p1.y() < m_rows * m_resolution);
-		assert(p2.x() >= 0 && p2.x() < m_cols * m_resolution);
-		assert(p2.y() >= 0 && p2.y() < m_rows * m_resolution);
+        assert(p1.x() >= 0 && size_t(p1.x()) < m_cols * m_resolution);
+        assert(p1.y() >= 0 && size_t(p1.y()) < m_rows * m_resolution);
+        assert(p2.x() >= 0 && size_t(p2.x()) < m_cols * m_resolution);
+        assert(p2.y() >= 0 && size_t(p2.y()) < m_rows * m_resolution);
 		// Get the cells of the end points.
 		coord_t ix = p1(0) / m_resolution;
 		coord_t iy = p1(1) / m_resolution;
@@ -245,12 +245,10 @@ public:
 					return;
 	}
 
-	std::pair<std::vector<std::pair<size_t, size_t>>::const_iterator, std::vector<std::pair<size_t, size_t>>::const_iterator> cell_data_range(coord_t row, coord_t col) const
+    std::pair<std::vector<std::pair<size_t, size_t>>::const_iterator, std::vector<std::pair<size_t, size_t>>::const_iterator> cell_data_range(coord_t row, coord_t col) const
 	{
-		assert(row >= 0);
-		assert(row < m_rows);
-		assert(col >= 0);
-		assert(col < m_cols);
+        assert(row >= 0 && size_t(row) < m_rows);
+        assert(col >= 0 && size_t(col) < m_cols);
 		const EdgeGrid::Grid::Cell &cell = m_cells[row * m_cols + col];
 		return std::make_pair(m_cell_data.begin() + cell.begin, m_cell_data.begin() + cell.end);
 	}
diff --git a/src/libslic3r/Fill/FillAdaptive.cpp b/src/libslic3r/Fill/FillAdaptive.cpp
index 520124533..d8c05887e 100644
--- a/src/libslic3r/Fill/FillAdaptive.cpp
+++ b/src/libslic3r/Fill/FillAdaptive.cpp
@@ -160,66 +160,66 @@ bool triangle_AABB_intersects(const Vector &a, const Vector &b, const Vector &c,
     return true;
 }
 
-static double dist2_to_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, const Vec3d &p)
-{
-    double out = std::numeric_limits<double>::max();
-    const Vec3d v1 = b - a;
-    auto        l1 = v1.squaredNorm();
-    const Vec3d v2 = c - b;
-    auto        l2 = v2.squaredNorm();
-    const Vec3d v3 = a - c;
-    auto        l3 = v3.squaredNorm();
+//    static double dist2_to_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, const Vec3d &p)
+//    {
+//        double out = std::numeric_limits<double>::max();
+//        const Vec3d v1 = b - a;
+//        auto        l1 = v1.squaredNorm();
+//        const Vec3d v2 = c - b;
+//        auto        l2 = v2.squaredNorm();
+//        const Vec3d v3 = a - c;
+//        auto        l3 = v3.squaredNorm();
 
-    // Is the triangle valid?
-    if (l1 > 0. && l2 > 0. && l3 > 0.) 
-    {
-        // 1) Project point into the plane of the triangle.
-        const Vec3d n = v1.cross(v2);
-        double d = (p - a).dot(n);
-        const Vec3d foot_pt = p - n * d / n.squaredNorm();
+//        // Is the triangle valid?
+//        if (l1 > 0. && l2 > 0. && l3 > 0.)
+//        {
+//            // 1) Project point into the plane of the triangle.
+//            const Vec3d n = v1.cross(v2);
+//            double d = (p - a).dot(n);
+//            const Vec3d foot_pt = p - n * d / n.squaredNorm();
 
-        // 2) Maximum projection of n.
-        int proj_axis;
-        n.array().cwiseAbs().maxCoeff(&proj_axis);
+//            // 2) Maximum projection of n.
+//            int proj_axis;
+//            n.array().cwiseAbs().maxCoeff(&proj_axis);
 
-        // 3) Test whether the foot_pt is inside the triangle.
-        {
-            auto inside_triangle = [](const Vec2d& v1, const Vec2d& v2, const Vec2d& v3, const Vec2d& pt) {
-                const double d1 = cross2(v1, pt);
-                const double d2 = cross2(v2, pt);
-                const double d3 = cross2(v3, pt);
-                // Testing both CCW and CW orientations.
-                return (d1 >= 0. && d2 >= 0. && d3 >= 0.) || (d1 <= 0. && d2 <= 0. && d3 <= 0.);
-            };
-            bool inside;
-            switch (proj_axis) {
-            case 0: 
-                inside = inside_triangle({v1.y(), v1.z()}, {v2.y(), v2.z()}, {v3.y(), v3.z()}, {foot_pt.y(), foot_pt.z()}); break;
-            case 1: 
-                inside = inside_triangle({v1.z(), v1.x()}, {v2.z(), v2.x()}, {v3.z(), v3.x()}, {foot_pt.z(), foot_pt.x()}); break;
-            default: 
-                assert(proj_axis == 2);
-                inside = inside_triangle({v1.x(), v1.y()}, {v2.x(), v2.y()}, {v3.x(), v3.y()}, {foot_pt.x(), foot_pt.y()}); break;
-            }
-            if (inside)
-                return (p - foot_pt).squaredNorm();
-        }
+//            // 3) Test whether the foot_pt is inside the triangle.
+//            {
+//                auto inside_triangle = [](const Vec2d& v1, const Vec2d& v2, const Vec2d& v3, const Vec2d& pt) {
+//                    const double d1 = cross2(v1, pt);
+//                    const double d2 = cross2(v2, pt);
+//                    const double d3 = cross2(v3, pt);
+//                    // Testing both CCW and CW orientations.
+//                    return (d1 >= 0. && d2 >= 0. && d3 >= 0.) || (d1 <= 0. && d2 <= 0. && d3 <= 0.);
+//                };
+//                bool inside;
+//                switch (proj_axis) {
+//                case 0:
+//                    inside = inside_triangle({v1.y(), v1.z()}, {v2.y(), v2.z()}, {v3.y(), v3.z()}, {foot_pt.y(), foot_pt.z()}); break;
+//                case 1:
+//                    inside = inside_triangle({v1.z(), v1.x()}, {v2.z(), v2.x()}, {v3.z(), v3.x()}, {foot_pt.z(), foot_pt.x()}); break;
+//                default:
+//                    assert(proj_axis == 2);
+//                    inside = inside_triangle({v1.x(), v1.y()}, {v2.x(), v2.y()}, {v3.x(), v3.y()}, {foot_pt.x(), foot_pt.y()}); break;
+//                }
+//                if (inside)
+//                    return (p - foot_pt).squaredNorm();
+//            }
 
-        // 4) Find minimum distance to triangle vertices and edges.
-        out = std::min((p - a).squaredNorm(), std::min((p - b).squaredNorm(), (p - c).squaredNorm()));
-        auto t = (p - a).dot(v1);
-        if (t > 0. && t < l1)
-            out = std::min(out, (a + v1 * (t / l1) - p).squaredNorm());
-        t = (p - b).dot(v2);
-        if (t > 0. && t < l2)
-            out = std::min(out, (b + v2 * (t / l2) - p).squaredNorm());
-        t = (p - c).dot(v3);
-        if (t > 0. && t < l3)
-            out = std::min(out, (c + v3 * (t / l3) - p).squaredNorm());
-    }
+//            // 4) Find minimum distance to triangle vertices and edges.
+//            out = std::min((p - a).squaredNorm(), std::min((p - b).squaredNorm(), (p - c).squaredNorm()));
+//            auto t = (p - a).dot(v1);
+//            if (t > 0. && t < l1)
+//                out = std::min(out, (a + v1 * (t / l1) - p).squaredNorm());
+//            t = (p - b).dot(v2);
+//            if (t > 0. && t < l2)
+//                out = std::min(out, (b + v2 * (t / l2) - p).squaredNorm());
+//            t = (p - c).dot(v3);
+//            if (t > 0. && t < l3)
+//                out = std::min(out, (c + v3 * (t / l3) - p).squaredNorm());
+//        }
 
-    return out;
-}
+//        return out;
+//    }
 
 // Ordering of children cubes.
 static const std::array<Vec3d, 8> child_centers {
@@ -690,7 +690,8 @@ static void add_hook(
 
     // Trim the hook start by the infill line it will connect to.
     Point hook_start;
-    bool  intersection_found = intersection.intersect_line->intersection(
+
+    [[maybe_unused]] bool intersection_found = intersection.intersect_line->intersection(
         create_offset_line(*intersection.closest_line, intersection, scaled_offset),
         &hook_start);
     assert(intersection_found);
@@ -703,7 +704,7 @@ static void add_hook(
     Vector  hook_vector      = ((hook_length + 1.16 * scaled_trim_distance) * hook_vector_norm).cast<coord_t>();
     Line    hook_forward(hook_start, hook_start + hook_vector);
 
-    auto filter_itself = [&intersection, &lines_src](const auto &item) { return item.second != intersection.intersect_line - lines_src.data(); };
+    auto filter_itself = [&intersection, &lines_src](const auto &item) { return item.second != (long unsigned int)(intersection.intersect_line - lines_src.data()); };
 
     std::vector<std::pair<rtree_segment_t, size_t>> hook_intersections;
     rtree.query(bgi::intersects(mk_rtree_seg(hook_forward)) && bgi::satisfies(filter_itself), std::back_inserter(hook_intersections));
@@ -1178,7 +1179,8 @@ static Polylines connect_lines_using_hooks(Polylines &&lines, const ExPolygon &b
                 rtree.query(
                     bgi::intersects(mk_rtree_seg(first_i_point, nearest_i_point)) &&
                     bgi::satisfies([&first_i, &nearest_i, &lines_src](const auto &item) 
-                        { return item.second != first_i.intersect_line - lines_src.data() && item.second != nearest_i.intersect_line - lines_src.data(); }),
+                        { return item.second != (long unsigned int)(first_i.intersect_line - lines_src.data())
+                              && item.second != (long unsigned int)(nearest_i.intersect_line - lines_src.data()); }),
                     std::back_inserter(closest));
                 could_connect = closest.empty();
 #if 0
@@ -1252,7 +1254,7 @@ static Polylines connect_lines_using_hooks(Polylines &&lines, const ExPolygon &b
             }
 #ifdef ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT
             ++ iStep;
-#endif ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT
+#endif // ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT
             first_i.used = true;
         }
     }
@@ -1410,15 +1412,15 @@ void Filler::_fill_surface_single(
 #endif /* ADAPTIVE_CUBIC_INFILL_DEBUG_OUTPUT */
 }
 
-static double bbox_max_radius(const BoundingBoxf3 &bbox, const Vec3d &center)
-{
-    const auto p = (bbox.min - center);
-    const auto s = bbox.size();
-    double r2max = 0.;
-    for (int i = 0; i < 8; ++ i)
-        r2max = std::max(r2max, (p + Vec3d(s.x() * double(i & 1), s.y() * double(i & 2), s.z() * double(i & 4))).squaredNorm());
-    return sqrt(r2max);
-}
+//static double bbox_max_radius(const BoundingBoxf3 &bbox, const Vec3d &center)
+//{
+//    const auto p = (bbox.min - center);
+//    const auto s = bbox.size();
+//    double r2max = 0.;
+//    for (int i = 0; i < 8; ++ i)
+//        r2max = std::max(r2max, (p + Vec3d(s.x() * double(i & 1), s.y() * double(i & 2), s.z() * double(i & 4))).squaredNorm());
+//    return sqrt(r2max);
+//}
 
 static std::vector<CubeProperties> make_cubes_properties(double max_cube_edge_length, double line_spacing)
 {
@@ -1513,8 +1515,10 @@ void Octree::insert_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, Cub
     assert(current_cube);
     assert(depth > 0);
 
+    --depth;
+
     // Squared radius of a sphere around the child cube.
-    const double r2_cube = Slic3r::sqr(0.5 * this->cubes_properties[-- depth].height + EPSILON);
+    // const double r2_cube = Slic3r::sqr(0.5 * this->cubes_properties[depth].height + EPSILON);
 
     for (size_t i = 0; i < 8; ++ i) {
         const Vec3d &child_center_dir = child_centers[i];
@@ -1532,6 +1536,7 @@ void Octree::insert_triangle(const Vec3d &a, const Vec3d &b, const Vec3d &c, Cub
         }
         Vec3d child_center = current_cube->center + (child_center_dir * (this->cubes_properties[depth].edge_length / 2.));
         //if (dist2_to_triangle(a, b, c, child_center) < r2_cube) {
+        // dist2_to_triangle and r2_cube are commented out too.
         if (triangle_AABB_intersects(a, b, c, bbox)) {
             if (! current_cube->children[i])
                 current_cube->children[i] = this->pool.construct(child_center);
diff --git a/src/libslic3r/Fill/FillAdaptive.hpp b/src/libslic3r/Fill/FillAdaptive.hpp
index 330cb8a46..0578cc3e1 100644
--- a/src/libslic3r/Fill/FillAdaptive.hpp
+++ b/src/libslic3r/Fill/FillAdaptive.hpp
@@ -59,7 +59,7 @@ public:
     ~Filler() override {}
 
 protected:
-    Fill* clone() const override { return new Filler(*this); };
+    Fill* clone() const override { return new Filler(*this); }
 	void _fill_surface_single(
 	    const FillParams                &params,
 	    unsigned int                     thickness_layers,
@@ -73,7 +73,7 @@ protected:
 	bool no_sort() const override { return false; }
 };
 
-}; // namespace FillAdaptive
+} // namespace FillAdaptive
 } // namespace Slic3r
 
 #endif // slic3r_FillAdaptive_hpp_
diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp
index 20d32f3e2..af53907c7 100644
--- a/src/libslic3r/Fill/FillBase.cpp
+++ b/src/libslic3r/Fill/FillBase.cpp
@@ -1170,15 +1170,15 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 					// Add these points to the destination contour.
                     const Polyline  &infill_line = infill_ordered[it->second / 2];
                     const Point     &pt          = (it->second & 1) ? infill_line.points.back() : infill_line.points.front();
-#ifndef NDEBUG
-                    {
-					    const Vec2d pt1 = ipt.cast<double>();
-					    const Vec2d pt2 = (idx_point + 1 == contour_src.size() ? contour_src.points.front() : contour_src.points[idx_point + 1]).cast<double>();
-					    const Vec2d ptx = lerp(pt1, pt2, it->first.t);
-                        assert(std::abs(pt.x() - pt.x()) < SCALED_EPSILON);
-                        assert(std::abs(pt.y() - pt.y()) < SCALED_EPSILON);
-                    }
-#endif // NDEBUG
+//#ifndef NDEBUG
+//                    {
+//					    const Vec2d pt1 = ipt.cast<double>();
+//					    const Vec2d pt2 = (idx_point + 1 == contour_src.size() ? contour_src.points.front() : contour_src.points[idx_point + 1]).cast<double>();
+//                      const Vec2d ptx = lerp(pt1, pt2, it->first.t);
+//                      assert(std::abs(ptx.x() - pt.x()) < SCALED_EPSILON);
+//                      assert(std::abs(ptx.y() - pt.y()) < SCALED_EPSILON);
+//                    }
+//#endif // NDEBUG
                     size_t idx_tjoint_pt = 0;
                     if (idx_point + 1 < contour_src.size() || pt != contour_dst.front()) {
                         if (pt != contour_dst.back())
@@ -1261,8 +1261,6 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
 	std::vector<ConnectionCost> connections_sorted;
 	connections_sorted.reserve(infill_ordered.size() * 2 - 2);
 	for (size_t idx_chain = 1; idx_chain < infill_ordered.size(); ++ idx_chain) {
-		const Polyline 						&pl1 			= infill_ordered[idx_chain - 1];
-		const Polyline 						&pl2 			= infill_ordered[idx_chain];
 		const ContourIntersectionPoint		*cp1			= &map_infill_end_point_to_boundary[(idx_chain - 1) * 2 + 1];
 		const ContourIntersectionPoint		*cp2			= &map_infill_end_point_to_boundary[idx_chain * 2];
 		if (cp1->contour_idx != boundary_idx_unconnected && cp1->contour_idx == cp2->contour_idx) {
@@ -1396,7 +1394,6 @@ void Fill::connect_infill(Polylines &&infill_ordered, const std::vector<const Po
         if (! contour_point.consumed && contour_point.contour_idx != boundary_idx_unconnected) {
             const Points              &contour        = boundary[contour_point.contour_idx];
             const std::vector<double> &contour_params = boundary_params[contour_point.contour_idx];
-            const size_t               contour_pt_idx = contour_point.point_idx;
 
             double    lprev         = contour_point.could_connect_prev() ?
                 path_length_along_contour_ccw(contour_point.prev_on_contour, &contour_point, contour_params.back()) :
diff --git a/src/libslic3r/Fill/FillRectilinear.cpp b/src/libslic3r/Fill/FillRectilinear.cpp
index f8393cf36..99d25b52a 100644
--- a/src/libslic3r/Fill/FillRectilinear.cpp
+++ b/src/libslic3r/Fill/FillRectilinear.cpp
@@ -515,8 +515,7 @@ static inline bool intersection_on_prev_next_vertical_line_valid(
     const SegmentedIntersectionLine &vline_other = segs[side == SegmentIntersection::Side::Right ? (iVerticalLine + 1) : (iVerticalLine - 1)];
     const SegmentIntersection       &it_other    = vline_other.intersections[iIntersectionOther];
     assert(it_other.is_inner());
-    assert(iIntersectionOther > 0);
-    assert(iIntersectionOther + 1 < vline_other.intersections.size());
+    assert(iIntersectionOther > 0 && size_t(iIntersectionOther + 1) < vline_other.intersections.size());
     // Is iIntersectionOther at the boundary of a vertical segment?
     const SegmentIntersection       &it_other2   = vline_other.intersections[it_other.is_low() ? iIntersectionOther - 1 : iIntersectionOther + 1];
     if (it_other2.is_inner())
@@ -1176,8 +1175,7 @@ static void pinch_contours_insert_phony_outer_intersections(std::vector<Segmente
                     assert(it->type == SegmentIntersection::OUTER_LOW);
                     ++ it;
                 } else {
-                    auto lo  = it;
-                    assert(lo->type == SegmentIntersection::INNER_LOW);
+                    assert(it->type == SegmentIntersection::INNER_LOW);
                     auto hi  = ++ it;
                     assert(hi->type == SegmentIntersection::INNER_HIGH);
                     auto lo2 = ++ it;
@@ -1186,11 +1184,11 @@ static void pinch_contours_insert_phony_outer_intersections(std::vector<Segmente
                         // In that case one shall insert a phony OUTER_HIGH / OUTER_LOW pair.
                         int up = hi->vertical_up();
                         int dn = lo2->vertical_down();
-#ifndef _NDEBUG
+
                         assert(up == -1 || up > 0);
                         assert(dn == -1 || dn >= 0);
                         assert((up == -1 && dn == -1) || (dn + 1 == up));
-#endif // _NDEBUG
+
                         bool pinched = dn + 1 != up;
                         if (pinched) {
                             // hi is not connected with its inner contour to lo2.
@@ -1267,10 +1265,6 @@ static const SegmentIntersection& end_of_vertical_run_raw(const SegmentIntersect
     }
     return *it;
 }
-static SegmentIntersection& end_of_vertical_run_raw(SegmentIntersection &start)
-{
-	return const_cast<SegmentIntersection&>(end_of_vertical_run_raw(std::as_const(start)));
-}
 
 // Find the last INNER_HIGH intersection starting with INNER_LOW, that is followed by OUTER_HIGH intersection, traversing vertical up contours if enabled.
 // Such intersection shall always exist.
@@ -1383,7 +1377,7 @@ static void traverse_graph_generate_polylines(
         bool 					   try_connect 	= false;
         if (going_up) {
             assert(! it->consumed_vertical_up);
-            assert(i_intersection + 1 < vline.intersections.size());
+            assert(size_t(i_intersection + 1) < vline.intersections.size());
             // Step back to the beginning of the vertical segment to mark it as consumed.
             if (it->is_inner()) {
                 assert(i_intersection > 0);
@@ -1395,7 +1389,7 @@ static void traverse_graph_generate_polylines(
                 it->consumed_vertical_up = true;
                 ++ it;
                 ++ i_intersection;
-                assert(i_intersection < vline.intersections.size());
+                assert(size_t(i_intersection) < vline.intersections.size());
             } while (it->type != SegmentIntersection::OUTER_HIGH);
             if ((it - 1)->is_inner()) {
                 // Step back.
@@ -1815,7 +1809,7 @@ static std::vector<MonotonicRegion> generate_montonous_regions(std::vector<Segme
         return false;
     };
 #else
-    auto test_overlap = [](int, int, int) { return false; };
+    [[maybe_unused]] auto test_overlap = [](int, int, int) { return false; };
 #endif
 
     for (int i_vline_seed = 0; i_vline_seed < int(segs.size()); ++ i_vline_seed) {
@@ -2033,8 +2027,7 @@ static void connect_monotonic_regions(std::vector<MonotonicRegion> &regions, con
 		map_intersection_to_region_end.emplace_back(&segs[region.right.vline].intersections[region.right.low], &region);
 	}
 	auto intersections_lower = [](const MapType &l, const MapType &r){ return l.first < r.first ; };
-	auto intersections_equal = [](const MapType &l, const MapType &r){ return l.first == r.first ; };
-	std::sort(map_intersection_to_region_start.begin(), map_intersection_to_region_start.end(), intersections_lower);
+    std::sort(map_intersection_to_region_start.begin(), map_intersection_to_region_start.end(), intersections_lower);
 	std::sort(map_intersection_to_region_end.begin(), map_intersection_to_region_end.end(), intersections_lower);
 
 	// Scatter links to neighboring regions.
@@ -2193,7 +2186,7 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
 	};
 	std::vector<NextCandidate> next_candidates;
 
-    auto validate_unprocessed = 
+    [[maybe_unused]]auto validate_unprocessed =
 #ifdef NDEBUG
         []() { return true; };
 #else
@@ -2222,7 +2215,7 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
                 } else {
                     // Some left neihgbor should not be processed yet.
                     assert(left_neighbors_unprocessed[i] > 1);
-                    size_t num_predecessors_unprocessed = 0;
+                    int32_t num_predecessors_unprocessed = 0;
                     bool   has_left_last_on_path       = false;
                     for (const MonotonicRegion* left : region.left_neighbors) {
                         size_t iprev = left - regions.data();
@@ -2290,8 +2283,7 @@ static std::vector<MonotonicRegionLink> chain_monotonic_regions(
 			NextCandidate 				 next_candidate;
 			next_candidate.probability = 0;
 			for (MonotonicRegion *next : region.right_neighbors) {
-				int &unprocessed = left_neighbors_unprocessed[next - regions.data()];
-				assert(unprocessed > 1);
+                assert(left_neighbors_unprocessed[next - regions.data()] > 1);
 				if (left_neighbors_unprocessed[next - regions.data()] == 2) {
 					// Dependencies of the successive blocks are satisfied.
                     AntPath &path1 = path_matrix(region, dir, *next, false);
@@ -2844,8 +2836,6 @@ bool FillRectilinear::fill_surface_by_multilines(const Surface *surface, FillPar
     coord_t line_spacing = coord_t(scale_(this->spacing) / params.density);
     std::pair<float, Point> rotate_vector = this->_infill_direction(surface);
     for (const SweepParams &sweep : sweep_params) {
-        size_t n_fill_lines_initial = fill_lines.size();
-
         // Rotate polygons so that we can work with vertical lines here
         double angle = rotate_vector.first + sweep.angle_base;
         ExPolygonWithOffset poly_with_offset(poly_with_offset_base, - angle);
diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp
index d553d727a..52861afba 100644
--- a/src/libslic3r/GCode/GCodeProcessor.cpp
+++ b/src/libslic3r/GCode/GCodeProcessor.cpp
@@ -50,11 +50,6 @@ const std::string GCodeProcessor::Width_Tag      = "WIDTH:";
 const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "MM3_PER_MM:";
 #endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
 
-static bool is_valid_extrusion_role(int value)
-{
-    return (static_cast<int>(erNone) <= value) && (value <= static_cast<int>(erMixed));
-}
-
 static void set_option_value(ConfigOptionFloats& option, size_t id, float value)
 {
     if (id < option.values.size())
@@ -2343,7 +2338,7 @@ void GCodeProcessor::process_T(const GCodeReader::GCodeLine& line)
 void GCodeProcessor::process_T(const std::string_view command)
 {
     if (command.length() > 1) {
-        int eid;
+        int eid = 0;
         if (! parse_number(command.substr(1), eid) || eid < 0 || eid > 255) {
             // T-1 is a valid gcode line for RepRap Firmwares (used to deselects all tools) see https://github.com/prusa3d/PrusaSlicer/issues/5677
             if ((m_flavor != gcfRepRapFirmware && m_flavor != gcfRepRapSprinter) || eid != -1)
diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp
index 5ce56896d..b3383fcc5 100644
--- a/src/libslic3r/LayerRegion.cpp
+++ b/src/libslic3r/LayerRegion.cpp
@@ -59,7 +59,7 @@ void LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollec
     const PrintRegionConfig &region_config = this->region()->config();
     // This needs to be in sync with PrintObject::_slice() slicing_mode_normal_below_layer!
     bool spiral_vase = print_config.spiral_vase &&
-        (this->layer()->id() >= region_config.bottom_solid_layers.value &&
+        (this->layer()->id() >= size_t(region_config.bottom_solid_layers.value) &&
          this->layer()->print_z >= region_config.bottom_solid_min_thickness - EPSILON);
 
     PerimeterGenerator g(
diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp
index b57ff0e14..c0f193f05 100644
--- a/src/libslic3r/PresetBundle.cpp
+++ b/src/libslic3r/PresetBundle.cpp
@@ -1145,33 +1145,26 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla
 
     for (const auto &section : tree) {
         PresetCollection         *presets = nullptr;
-        std::vector<std::string> *loaded  = nullptr;
         std::string               preset_name;
         PhysicalPrinterCollection *ph_printers = nullptr;
         std::string               ph_printer_name;
         if (boost::starts_with(section.first, "print:")) {
             presets = &this->prints;
-            loaded  = &loaded_prints;
             preset_name = section.first.substr(6);
         } else if (boost::starts_with(section.first, "filament:")) {
             presets = &this->filaments;
-            loaded  = &loaded_filaments;
             preset_name = section.first.substr(9);
         } else if (boost::starts_with(section.first, "sla_print:")) {
             presets = &this->sla_prints;
-            loaded  = &loaded_sla_prints;
             preset_name = section.first.substr(10);
         } else if (boost::starts_with(section.first, "sla_material:")) {
             presets = &this->sla_materials;
-            loaded  = &loaded_sla_materials;
             preset_name = section.first.substr(13);
         } else if (boost::starts_with(section.first, "printer:")) {
             presets = &this->printers;
-            loaded  = &loaded_printers;
             preset_name = section.first.substr(8);
         } else if (boost::starts_with(section.first, "physical_printer:")) {
             ph_printers = &this->physical_printers;
-            loaded  = &loaded_physical_printers;
             ph_printer_name = section.first.substr(17);
         } else if (section.first == "presets") {
             // Load the names of the active presets.

From 2d32c80b75437d4aa94fa7a47e4e13cc826ccc79 Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Thu, 14 Jan 2021 13:00:03 +0100
Subject: [PATCH 2/3] Fixing GCC warnings 2

---
 src/libslic3r/Fill/Fill.cpp                 |  1 -
 src/libslic3r/PerimeterGenerator.cpp        |  8 ++--
 src/libslic3r/SLA/SupportPointGenerator.cpp |  2 -
 src/libslic3r/ShortestPath.cpp              | 22 ++++-------
 src/libslic3r/VoronoiOffset.cpp             |  2 +
 src/slic3r/GUI/ConfigWizard.cpp             | 16 ++++----
 src/slic3r/GUI/Field.cpp                    |  6 +--
 src/slic3r/GUI/NotificationManager.cpp      | 42 +++++++++------------
 src/slic3r/GUI/NotificationManager.hpp      | 15 +++++---
 src/slic3r/GUI/OG_CustomCtrl.cpp            |  2 +-
 src/slic3r/GUI/OptionsGroup.cpp             | 15 ++++----
 src/slic3r/GUI/PrintHostDialogs.cpp         |  2 +-
 src/slic3r/GUI/Tab.cpp                      |  9 +----
 13 files changed, 61 insertions(+), 81 deletions(-)

diff --git a/src/libslic3r/Fill/Fill.cpp b/src/libslic3r/Fill/Fill.cpp
index 6dbfa18fa..18e03e005 100644
--- a/src/libslic3r/Fill/Fill.cpp
+++ b/src/libslic3r/Fill/Fill.cpp
@@ -512,7 +512,6 @@ void Layer::make_ironing()
 	};
 
 	std::vector<IroningParams> by_extruder;
-	bool   extruder_dont_care   = this->object()->config().wipe_into_objects;
     double default_layer_height = this->object()->config().layer_height;
 
 	for (LayerRegion *layerm : m_regions)
diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp
index a29f293ce..7a4bbe27a 100644
--- a/src/libslic3r/PerimeterGenerator.cpp
+++ b/src/libslic3r/PerimeterGenerator.cpp
@@ -166,7 +166,7 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
                 (float)perimeter_generator.layer_height);
             
             // get overhang paths by checking what parts of this loop fall 
-            // outside the grown lower slices (thus where the distance between
+            // outside the grown lower slices (thus where the distance between
             // the loop centerline and original lower slices is >= half nozzle diameter
             extrusion_paths_append(
                 paths,
@@ -396,8 +396,8 @@ void PerimeterGenerator::process()
     }
 
     // fuzzy skin configuration
-    double fuzzy_skin_thickness;
-    double fuzzy_skin_point_dist;
+    double fuzzy_skin_thickness = scale_(this->object_config->fuzzy_skin_thickness);
+    double fuzzy_skin_point_dist = scale_(this->object_config->fuzzy_skin_point_dist);
     //FuzzyShape fuzzy_skin_shape;
     if (this->object_config->fuzzy_skin_perimeter_mode != FuzzySkinPerimeterMode::None) {
         /*
@@ -419,8 +419,6 @@ void PerimeterGenerator::process()
             break;
         }
         */
-        fuzzy_skin_thickness  = scale_(this->object_config->fuzzy_skin_thickness);
-        fuzzy_skin_point_dist = scale_(this->object_config->fuzzy_skin_point_dist);
     }
 
     // we need to process each island separately because we might have different
diff --git a/src/libslic3r/SLA/SupportPointGenerator.cpp b/src/libslic3r/SLA/SupportPointGenerator.cpp
index 8f720339a..7a4c29068 100644
--- a/src/libslic3r/SLA/SupportPointGenerator.cpp
+++ b/src/libslic3r/SLA/SupportPointGenerator.cpp
@@ -304,8 +304,6 @@ void SupportPointGenerator::add_support_points(SupportPointGenerator::Structure
 
     float tp      = m_config.tear_pressure();
     float current = s.supports_force_total();
-    static constexpr float DANGL_DAMPING = .5f;
-    static constexpr float SLOPE_DAMPING = .1f;
 
     if (s.islands_below.empty()) {
         // completely new island - needs support no doubt
diff --git a/src/libslic3r/ShortestPath.cpp b/src/libslic3r/ShortestPath.cpp
index 3d5903df1..daffcd5f2 100644
--- a/src/libslic3r/ShortestPath.cpp
+++ b/src/libslic3r/ShortestPath.cpp
@@ -21,7 +21,7 @@ template<typename EndPointType, typename KDTreeType, typename CouldReverseFunc>
 std::vector<std::pair<size_t, bool>> chain_segments_closest_point(std::vector<EndPointType> &end_points, KDTreeType &kdtree, CouldReverseFunc &could_reverse_func, EndPointType &first_point)
 {
 	assert((end_points.size() & 1) == 0);
-	size_t num_segments = end_points.size() / 2;
+    size_t num_segments = end_points.size() / 2;
 	assert(num_segments >= 2);
 	for (EndPointType &ep : end_points)
 		ep.chain_id = 0;
@@ -1553,9 +1553,7 @@ static inline void reorder_by_two_exchanges_with_segment_flipping(std::vector<Fl
 		size_t crossover1_pos_final = std::numeric_limits<size_t>::max();
 		size_t crossover2_pos_final = std::numeric_limits<size_t>::max();
 		size_t crossover_flip_final = 0;
-		for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) {
-			double longest_connection_length = first_crossover_candidate.first;
-			size_t longest_connection_idx    = first_crossover_candidate.second;
+        for (const auto& [longest_connection_length, longest_connection_idx] : connection_lengths) {
 			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<size_t>::max();
@@ -1630,12 +1628,9 @@ static inline void reorder_by_three_exchanges_with_segment_flipping(std::vector<
 		size_t crossover2_pos_final = std::numeric_limits<size_t>::max();
 		size_t crossover3_pos_final = std::numeric_limits<size_t>::max();
 		size_t crossover_flip_final = 0;
-		for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) {
-			double longest_connection_length = first_crossover_candidate.first;
-			size_t longest_connection_idx    = first_crossover_candidate.second;
-			connection_tried[longest_connection_idx] = true;
+        for (const auto& [longest_connection_length, longest_connection_idx] : connection_lengths) {
+            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<size_t>::max();
 			double crossover_cost_min = connections.back().cost;
 			for (size_t j = 1; j < connections.size(); ++ j)
 				if (! connection_tried[j]) {
@@ -1789,12 +1784,9 @@ 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<double>::max());
 #endif /* NDEBUG */
-		for (const std::pair<double, size_t> &first_crossover_candidate : connection_lengths) {
-			double longest_connection_length = first_crossover_candidate.first;
-			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<size_t>::max();
+        for (const auto& [longest_connection_length, longest_connection_idx] : connection_lengths) {
+            connection_tried[longest_connection_idx] = true;
+            // Find the second crossover connection with the lowest total chain cost.
 			double crossover_cost_min = connections.back().cost;
 			for (size_t j = 1; j < connections.size(); ++ j)
 				if (! connection_tried[j]) {
diff --git a/src/libslic3r/VoronoiOffset.cpp b/src/libslic3r/VoronoiOffset.cpp
index c0541bd9f..f328a8ab2 100644
--- a/src/libslic3r/VoronoiOffset.cpp
+++ b/src/libslic3r/VoronoiOffset.cpp
@@ -561,9 +561,11 @@ Polygons voronoi_offset(
                 const Point &pt    = cell->contains_point() ?
                     ((cell->source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ? line0.a : line0.b) :
                     ((cell2->source_category() == boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT) ? line1.a : line1.b);
+            #ifndef NDEBUG
                 const Line  &line  = cell->contains_segment() ? line0 : line1;
                 assert(pt == line.a || pt == line.b);
                 assert((pt.cast<double>() - Vec2d(v0->x(), v0->y())).norm() < SCALED_EPSILON);
+            #endif // NDEBUG
                 Vec2d dir(v1->x() - v0->x(), v1->y() - v0->y());
                 double l2 = dir.squaredNorm();
                 if (offset_distance2 <= l2) {
diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp
index 5af48ee36..568c15a16 100644
--- a/src/slic3r/GUI/ConfigWizard.cpp
+++ b/src/slic3r/GUI/ConfigWizard.cpp
@@ -734,7 +734,7 @@ void PageMaterials::set_compatible_printers_html_window(const std::vector<std::s
             , text_clr_str
             , first_line
             , second_line);
-        for (int i = 0; i < printer_names.size(); ++i)
+        for (size_t i = 0; i < printer_names.size(); ++i)
         {
             text += wxString::Format("<td>%s</td>", boost::nowide::widen(printer_names[i]));
             if (i % 3 == 2) {
@@ -830,7 +830,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
                 }
             }
 			if (sel_printers[0] != 0) {
-				for (size_t i = 0; i < sel_printers_count; i++) {
+                for (int i = 0; i < sel_printers_count; i++) {
 					const std::string& printer_name = list_printer->get_data(sel_printers[i]);
 					const Preset* printer = nullptr;
 					for (const Preset* it : materials->printers) {
@@ -881,7 +881,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
 		if (sel_printers_count != 0 && sel_type != wxNOT_FOUND) {
 			const std::string& type = list_type->get_data(sel_type);
 			// find printer preset
-			for (size_t i = 0; i < sel_printers_count; i++) {
+            for (int i = 0; i < sel_printers_count; i++) {
 				const std::string& printer_name = list_printer->get_data(sel_printers[i]);
 				const Preset* printer = nullptr;
 				for (const Preset* it : materials->printers) {
@@ -917,7 +917,7 @@ void PageMaterials::update_lists(int sel_printer, int sel_type, int sel_vendor)
 			const std::string& vendor = list_vendor->get_data(sel_vendor);
 			// finst printer preset
             std::vector<ProfilePrintData> to_list;
-			for (size_t i = 0; i < sel_printers_count; i++) {
+            for (int i = 0; i < sel_printers_count; i++) {
 				const std::string& printer_name = list_printer->get_data(sel_printers[i]);
 				const Preset* printer = nullptr;
 				for (const Preset* it : materials->printers) {
@@ -986,7 +986,7 @@ void PageMaterials::sort_list_data(StringList* list, bool add_All_item, bool mat
         
         const ConfigOptionDef* def = print_config_def.get("filament_type");
         std::vector<std::string>enum_values = def->enum_values;
-        int end_of_sorted = 0;
+        size_t end_of_sorted = 0;
         for (size_t vals = 0; vals < enum_values.size(); vals++) {
             for (size_t profs = end_of_sorted; profs < other_profiles.size(); profs++)
             {
@@ -1044,13 +1044,11 @@ void PageMaterials::sort_list_data(PresetList* list, const std::vector<ProfilePr
         return a.name.get() < b.name.get();
         });
     list->Clear();
-    //for (const auto& item : prusa_profiles)
-    for (int i = 0; i < prusa_profiles.size(); ++i) {
+    for (size_t i = 0; i < prusa_profiles.size(); ++i) {
         list->append(std::string(prusa_profiles[i].name) + (prusa_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(prusa_profiles[i].name.get()));
         list->Check(i, prusa_profiles[i].checked);
     }
-    //for (const auto& item : other_profiles)
-    for (int i = 0; i < other_profiles.size(); ++i) {
+    for (size_t i = 0; i < other_profiles.size(); ++i) {
         list->append(std::string(other_profiles[i].name) + (other_profiles[i].omnipresent ? "" : " *"), &const_cast<std::string&>(other_profiles[i].name.get()));
         list->Check(i + prusa_profiles.size(), other_profiles[i].checked);
     }
diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp
index dfe95e71e..fc8b25efa 100644
--- a/src/slic3r/GUI/Field.cpp
+++ b/src/slic3r/GUI/Field.cpp
@@ -1028,7 +1028,7 @@ void Choice::set_selection()
 	}
 
 	if (!text_value.IsEmpty()) {
-		int idx = 0;
+        size_t idx = 0;
 		for (auto el : m_opt.enum_values) {
 			if (el == text_value)
 				break;
@@ -1375,7 +1375,7 @@ void ColourPicker::msw_rescale()
         size.SetHeight(m_opt.height * m_em_unit);
     else if (parent_is_custom_ctrl && opt_height > 0)
         size.SetHeight(lround(opt_height * m_em_unit));
-	if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
+    if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
     if (parent_is_custom_ctrl)
         field->SetSize(size);
     else
@@ -1402,7 +1402,7 @@ void PointCtrl::BUILD()
     if (parent_is_custom_ctrl && m_opt.height < 0)
         opt_height = (double)x_textctrl->GetSize().GetHeight() / m_em_unit;
 
-	x_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
+    x_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
 	x_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
 	y_textctrl->SetFont(Slic3r::GUI::wxGetApp().normal_font());
 	y_textctrl->SetBackgroundStyle(wxBG_STYLE_PAINT);
diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp
index 98cbf1e55..b0d0a556c 100644
--- a/src/slic3r/GUI/NotificationManager.cpp
+++ b/src/slic3r/GUI/NotificationManager.cpp
@@ -392,18 +392,18 @@ void NotificationManager::PopNotification::count_spaces()
 }
 void NotificationManager::PopNotification::init()
 {
-	std::string text          = m_text1 + " " + m_hypertext;
-	int         last_end      = 0;
-	            m_lines_count = 0;
+    std::string text          = m_text1 + " " + m_hypertext;
+    size_t      last_end      = 0;
+    m_lines_count = 0;
 
 	count_spaces();
-	
+
 	// count lines
 	m_endlines.clear();
 	while (last_end < text.length() - 1)
 	{
-		int next_hard_end = text.find_first_of('\n', last_end);
-		if (next_hard_end > 0 && ImGui::CalcTextSize(text.substr(last_end, next_hard_end - last_end).c_str()).x < m_window_width - m_window_width_offset) {
+        size_t next_hard_end = text.find_first_of('\n', last_end);
+        if (next_hard_end != std::string::npos && ImGui::CalcTextSize(text.substr(last_end, next_hard_end - last_end).c_str()).x < m_window_width - m_window_width_offset) {
 			//next line is ended by '/n'
 			m_endlines.push_back(next_hard_end);
 			last_end = next_hard_end + 1;
@@ -411,9 +411,9 @@ void NotificationManager::PopNotification::init()
 			// find next suitable endline
 			if (ImGui::CalcTextSize(text.substr(last_end).c_str()).x >= m_window_width - m_window_width_offset) {
 				// more than one line till end
-				int next_space = text.find_first_of(' ', last_end);
+                size_t next_space = text.find_first_of(' ', last_end);
 				if (next_space > 0) {
-					int next_space_candidate = text.find_first_of(' ', next_space + 1);
+                    size_t next_space_candidate = text.find_first_of(' ', next_space + 1);
 					while (next_space_candidate > 0 && ImGui::CalcTextSize(text.substr(last_end, next_space_candidate - last_end).c_str()).x < m_window_width - m_window_width_offset) {
 						next_space = next_space_candidate;
 						next_space_candidate = text.find_first_of(' ', next_space + 1);
@@ -456,7 +456,6 @@ void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& im
 void NotificationManager::PopNotification::render_text(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
 {
 	ImVec2      win_size(win_size_x, win_size_y);
-	ImVec2      win_pos(win_pos_x, win_pos_y);
 	float       x_offset = m_left_indentation;
 	std::string fulltext = m_text1 + m_hypertext; //+ m_text2;
 	ImVec2      text_size = ImGui::CalcTextSize(fulltext.c_str());
@@ -594,8 +593,6 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img
 {
 	ImVec2 win_size(win_size_x, win_size_y);
 	ImVec2 win_pos(win_pos_x, win_pos_y); 
-	ImVec4 orange_color = ImGui::GetStyleColorVec4(ImGuiCol_Button);
-	orange_color.w = 0.8f;
 	ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
 	ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
 	Notifications_Internal::push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_fading_out, m_current_fade_opacity);
@@ -831,9 +828,7 @@ void NotificationManager::SlicingCompleteLargeNotification::render_text(ImGuiWra
 	if (!m_is_large)
 		PopNotification::render_text(imgui, win_size_x, win_size_y, win_pos_x, win_pos_y);
 	else {
-		ImVec2 win_size(win_size_x, win_size_y);
-		ImVec2 win_pos(win_pos_x, win_pos_y);
-
+        ImVec2 win_size(win_size_x, win_size_y);
 		ImVec2 text1_size = ImGui::CalcTextSize(m_text1.c_str());
 		float x_offset = m_left_indentation;
 		std::string fulltext = m_text1 + m_hypertext + m_text2;
@@ -889,15 +884,12 @@ void NotificationManager::ExportFinishedNotification::count_spaces()
 void NotificationManager::ExportFinishedNotification::render_text(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
 {
 	
-	ImVec2      win_size(win_size_x, win_size_y);
-	ImVec2      win_pos(win_pos_x, win_pos_y);
 	float       x_offset = m_left_indentation;
 	std::string fulltext = m_text1 + m_hypertext; //+ m_text2;
-	ImVec2      text_size = ImGui::CalcTextSize(fulltext.c_str());
 	// Lines are always at least two and m_multiline is always true for ExportFinishedNotification.
 	// First line has "Export Finished" text and than hyper text open folder.
 	// Following lines are path to gcode.
-	int last_end = 0;
+    size_t last_end = 0;
 	float starting_y = m_line_height / 2;//10;
 	float shift_y = m_line_height;// -m_line_height / 20;
 	for (size_t i = 0; i < m_lines_count; i++) {
@@ -926,8 +918,6 @@ void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiW
 {
 	ImVec2 win_size(win_size_x, win_size_y);
 	ImVec2 win_pos(win_pos_x, win_pos_y);
-	ImVec4 orange_color = ImGui::GetStyleColorVec4(ImGuiCol_Button);
-	orange_color.w = 0.8f;
 	ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
 	ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
 	Notifications_Internal::push_style_color(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f), m_fading_out, m_current_fade_opacity);
@@ -1003,7 +993,6 @@ void NotificationManager::ProgressBarNotification::render_text(ImGuiWrapper& img
 }
 void NotificationManager::ProgressBarNotification::render_bar(ImGuiWrapper& imgui, const float win_size_x, const float win_size_y, const float win_pos_x, const float win_pos_y)
 {
-	float bar_y = win_size_y / 2 - win_size_y / 6 + m_line_height;
 	ImVec4 orange_color = ImVec4(.99f, .313f, .0f, 1.0f);
 	float  invisible_length = 0;//((float)(m_data.duration - m_remaining_time) / (float)m_data.duration * win_size_x);
 	//invisible_length -= win_size_x / ((float)m_data.duration * 60.f) * (60 - m_countdown_frame);
@@ -1141,12 +1130,17 @@ void NotificationManager::push_slicing_complete_notification(int timestamp, bool
 	int         time = 10;
     if (has_slicing_error_notification())
         return;
-	if (large) {
+    if (large) {
 		hypertext = _u8L("Export G-Code.");
 		time = 0;
 	}
-	NotificationData data{ NotificationType::SlicingComplete, NotificationLevel::RegularNotification, time,  _u8L("Slicing finished."), hypertext, [](wxEvtHandler* evnthndlr){
-		if (evnthndlr != nullptr) wxPostEvent(evnthndlr, ExportGcodeNotificationClickedEvent(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED)); return true; } };
+    NotificationData data{ NotificationType::SlicingComplete, NotificationLevel::RegularNotification, time,  _u8L("Slicing finished."), hypertext,
+                           [](wxEvtHandler* evnthndlr){
+                               if (evnthndlr != nullptr)
+                                   wxPostEvent(evnthndlr, ExportGcodeNotificationClickedEvent(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED));
+                               return true;
+                           }
+    };
 	push_notification_data(std::make_unique<NotificationManager::SlicingCompleteLargeNotification>(data, m_id_provider, m_evt_handler, large), timestamp);
 }
 void NotificationManager::set_slicing_complete_print_time(const std::string &info)
diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp
index 9252190ef..e3e50a3e3 100644
--- a/src/slic3r/GUI/NotificationManager.hpp
+++ b/src/slic3r/GUI/NotificationManager.hpp
@@ -339,14 +339,14 @@ private:
 		// Height of text
 		// Used as basic scaling unit!
 		float            m_line_height;
-		std::vector<int> m_endlines;
+        std::vector<size_t> m_endlines;
 		// Gray are f.e. eorrors when its uknown if they are still valid
 		bool             m_is_gray              { false };
 		//if multiline = true, notification is showing all lines(>2)
 		bool             m_multiline            { false };
 		// True if minimized button is rendered, helps to decide where is area for invisible close button
 		bool             m_minimize_b_visible   { false };
-		int              m_lines_count{ 1 };
+        size_t           m_lines_count{ 1 };
 	    // Target for wxWidgets events sent by clicking on the hyperlink available at some notifications.
 		wxEvtHandler*    m_evt_handler;
 	};
@@ -366,7 +366,7 @@ private:
 			                     override;
 		bool        m_is_large;
 		bool        m_has_print_info { false };
-		std::string m_print_info { std::string() };
+        std::string m_print_info;
 	};
 
 	class SlicingWarningNotification : public PopNotification
@@ -471,8 +471,13 @@ private:
 		{NotificationType::Mouse3dDisconnected, NotificationLevel::RegularNotification, 10,  _u8L("3D Mouse disconnected.") },
 //		{NotificationType::Mouse3dConnected, NotificationLevel::RegularNotification, 5,  _u8L("3D Mouse connected.") },
 //		{NotificationType::NewPresetsAviable, NotificationLevel::ImportantNotification, 20,  _u8L("New Presets are available."),  _u8L("See here.") },
-		{NotificationType::PresetUpdateAvailable, NotificationLevel::ImportantNotification, 20,  _u8L("Configuration update is available."),  _u8L("See more."), [](wxEvtHandler* evnthndlr){
-			if (evnthndlr != nullptr) wxPostEvent(evnthndlr, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED)); return true; }},
+        {NotificationType::PresetUpdateAvailable, NotificationLevel::ImportantNotification, 20,  _u8L("Configuration update is available."),  _u8L("See more."),
+             [](wxEvtHandler* evnthndlr) {
+                 if (evnthndlr != nullptr)
+                     wxPostEvent(evnthndlr, PresetUpdateAvailableClickedEvent(EVT_PRESET_UPDATE_AVAILABLE_CLICKED));
+                 return true;
+             }
+        },
 		{NotificationType::NewAppAvailable, NotificationLevel::ImportantNotification, 20,  _u8L("New version is available."),  _u8L("See Releases page."), [](wxEvtHandler* evnthndlr){ 
 				wxLaunchDefaultBrowser("https://github.com/prusa3d/PrusaSlicer/releases"); return true; }},
 		{NotificationType::EmptyColorChangeCode, NotificationLevel::RegularNotification, 10,  
diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp
index 1e581e70b..6433bf2d1 100644
--- a/src/slic3r/GUI/OG_CustomCtrl.cpp
+++ b/src/slic3r/GUI/OG_CustomCtrl.cpp
@@ -98,7 +98,7 @@ void OG_CustomCtrl::init_ctrl_lines()
             ctrl_lines.emplace_back(CtrlLine(height, this, line, false, opt_group->staticbox));
         }
         else
-            int i = 0;
+            assert(false);
     }
 }
 
diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp
index 5f9391645..8f5e20241 100644
--- a/src/slic3r/GUI/OptionsGroup.cpp
+++ b/src/slic3r/GUI/OptionsGroup.cpp
@@ -250,9 +250,8 @@ void OptionsGroup::activate_line(Line& line)
     if (custom_ctrl)
         m_use_custom_ctrl_as_parent = true;
 
-	// if we have an extra column, build it
-	if (extra_column)
-	{
+    // if we have an extra column, build it
+    if (extra_column) {
 		m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line));
 		grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
 	}
@@ -309,8 +308,8 @@ void OptionsGroup::activate_line(Line& line)
 	auto sizer = new wxBoxSizer(wxHORIZONTAL);
     if (!custom_ctrl)
         grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
-	// If we have a single option with no sidetext just add it directly to the grid sizer
-	if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
+    // If we have a single option with no sidetext just add it directly to the grid sizer
+    if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
         option_set.front().opt.label.empty() &&
 		option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
 		const auto& option = option_set.front();
@@ -319,16 +318,16 @@ void OptionsGroup::activate_line(Line& line)
         if (!custom_ctrl) {
             if (is_window_field(field))
                 sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0,
-                    wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2);
+                    wxBOTTOM | wxTOP | (option.opt.full_width ? int(wxEXPAND) : int(wxALIGN_CENTER_VERTICAL)), (wxOSX || !staticbox) ? 0 : 2);
             if (is_sizer_field(field))
-                sizer->Add(field->getSizer(), 1, option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL, 0);
+                sizer->Add(field->getSizer(), 1, (option.opt.full_width ? int(wxEXPAND) : int(wxALIGN_CENTER_VERTICAL)), 0);
         }
         return;
 	}
 
     for (auto opt : option_set) {
 		ConfigOptionDef option = opt.opt;
-		wxSizer* sizer_tmp = sizer;
+        wxSizer* sizer_tmp = sizer;
 		// add label if any
 		if (!option.label.empty() && !custom_ctrl) {
 //!			To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp
index 75f6d265d..cb4c22299 100644
--- a/src/slic3r/GUI/PrintHostDialogs.cpp
+++ b/src/slic3r/GUI/PrintHostDialogs.cpp
@@ -333,7 +333,7 @@ void PrintHostQueueDialog::on_cancel(Event &evt)
 void PrintHostQueueDialog::get_active_jobs(std::vector<std::pair<std::string, std::string>>& ret)
 {
     int ic = job_list->GetItemCount();
-    for (size_t i = 0; i < ic; i++)
+    for (int i = 0; i < ic; i++)
     {
         auto item = job_list->RowToItem(i);
         auto data = job_list->GetItemData(item);
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 974b709f7..eb9659c8a 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -411,11 +411,6 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
         }
     }
     // Initialize the page.
-#ifdef __WXOSX__
-    auto panel = m_tmp_panel;
-#else
-    auto panel = this;
-#endif
     PageShp page(new Page(m_page_view, title, icon_idx));
 //	page->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
 #ifdef __WINDOWS__
@@ -2999,8 +2994,8 @@ void Tab::update_btns_enabling()
     // we can delete any preset from the physical printer
     // and any user preset
     const Preset& preset = m_presets->get_edited_preset();
-    m_btn_delete_preset->Show(m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection() || 
-                              !preset.is_default && !preset.is_system);
+    m_btn_delete_preset->Show((m_type == Preset::TYPE_PRINTER && m_preset_bundle->physical_printers.has_selection())
+                              || (!preset.is_default && !preset.is_system));
 
     if (m_btn_edit_ph_printer)
         m_btn_edit_ph_printer->SetToolTip( m_preset_bundle->physical_printers.has_selection() ?

From d9c9de8eeec623d2c56e7c499d35f84ef7b88090 Mon Sep 17 00:00:00 2001
From: Lukas Matena <lukasmatena@seznam.cz>
Date: Fri, 29 Jan 2021 07:39:27 +0100
Subject: [PATCH 3/3] Fixing GCC warnings 3

---
 src/slic3r/GUI/BonjourDialog.cpp        | 24 ++++++++++++++++--------
 src/slic3r/GUI/BonjourDialog.hpp        |  1 +
 src/slic3r/GUI/DoubleSlider.cpp         | 22 +++++++++++-----------
 src/slic3r/GUI/GCodeViewer.cpp          | 21 +++++++++++----------
 src/slic3r/GUI/GCodeViewer.hpp          |  2 +-
 src/slic3r/GUI/GLCanvas3D.cpp           |  2 +-
 src/slic3r/GUI/GUI_App.cpp              |  2 +-
 src/slic3r/GUI/GUI_Preview.cpp          | 14 +++++++-------
 src/slic3r/GUI/InstanceCheck.cpp        |  4 ++--
 src/slic3r/GUI/Plater.cpp               | 12 +++++++-----
 src/slic3r/GUI/PresetComboBoxes.cpp     |  2 +-
 src/slic3r/GUI/Search.cpp               |  6 ------
 src/slic3r/GUI/Selection.cpp            |  2 +-
 src/slic3r/GUI/UnsavedChangesDialog.cpp |  2 +-
 src/slic3r/GUI/fts_fuzzy_match.h        | 13 +++++++------
 15 files changed, 68 insertions(+), 61 deletions(-)

diff --git a/src/slic3r/GUI/BonjourDialog.cpp b/src/slic3r/GUI/BonjourDialog.cpp
index 8ee01c949..51f18dce7 100644
--- a/src/slic3r/GUI/BonjourDialog.cpp
+++ b/src/slic3r/GUI/BonjourDialog.cpp
@@ -108,8 +108,7 @@ bool BonjourDialog::show_and_lookup()
 	timer->SetOwner(this);
 	timer_state = 1;
 	timer->Start(1000);
-	wxTimerEvent evt_dummy;
-	on_timer(evt_dummy);
+    on_timer_process();
 
 	// The background thread needs to queue messages for this dialog
 	// and for that it needs a valid pointer to it (mandated by the wxWidgets API).
@@ -214,18 +213,27 @@ void BonjourDialog::on_reply(BonjourReplyEvent &e)
 }
 
 void BonjourDialog::on_timer(wxTimerEvent &)
+{
+    on_timer_process();
+}
+
+// This is here so the function can be bound to wxEVT_TIMER and also called
+// explicitly (wxTimerEvent should not be created by user code).
+void BonjourDialog::on_timer_process()
 {
     const auto search_str = _utf8(L("Searching for devices"));
 
-	if (timer_state > 0) {
-		const std::string dots(timer_state, '.');
+    if (timer_state > 0) {
+        const std::string dots(timer_state, '.');
         label->SetLabel(GUI::from_u8((boost::format("%1% %2%") % search_str % dots).str()));
-		timer_state = (timer_state) % 3 + 1;
-	} else {
+        timer_state = (timer_state) % 3 + 1;
+    } else {
         label->SetLabel(GUI::from_u8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str()));
-		timer->Stop();
-	}
+        timer->Stop();
+    }
 }
 
 
+
+
 }
diff --git a/src/slic3r/GUI/BonjourDialog.hpp b/src/slic3r/GUI/BonjourDialog.hpp
index a9a33d522..def0838d7 100644
--- a/src/slic3r/GUI/BonjourDialog.hpp
+++ b/src/slic3r/GUI/BonjourDialog.hpp
@@ -43,6 +43,7 @@ private:
 
 	void on_reply(BonjourReplyEvent &);
 	void on_timer(wxTimerEvent &);
+    void on_timer_process();
 };
 
 
diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp
index 7ee5579e7..1e4eed1e8 100644
--- a/src/slic3r/GUI/DoubleSlider.cpp
+++ b/src/slic3r/GUI/DoubleSlider.cpp
@@ -317,7 +317,7 @@ double Control::get_double_value(const SelectedSlider& selection)
 {
     if (m_values.empty() || m_lower_value<0)
         return 0.0;
-    if (m_values.size() <= m_higher_value) {
+    if (m_values.size() <= size_t(m_higher_value)) {
         correct_higher_value();
         return m_values.back();
     }
@@ -621,7 +621,7 @@ static std::string short_and_splitted_time(const std::string& time)
             ::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
         else if (hours > 10 && minutes > 10 && seconds > 10)
             ::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds);
-        else if (minutes < 10 && seconds > 10 || minutes > 10 && seconds < 10)
+        else if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
             ::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds);
         else
             ::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds);
@@ -639,15 +639,15 @@ static std::string short_and_splitted_time(const std::string& time)
 
 wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const
 {
-    const int value = tick;
+    const size_t value = tick;
 
     if (m_label_koef == 1.0 && m_values.empty())
-        return wxString::Format("%d", value);
+        return wxString::Format("%lu", static_cast<unsigned long>(value));
     if (value >= m_values.size())
         return "ErrVal";
 
     if (m_draw_mode == dmSequentialGCodeView)
-        return wxString::Format("%d", static_cast<unsigned int>(m_values[value]));
+        return wxString::Format("%lu", static_cast<unsigned long>(m_values[value]));
     else {
         if (label_type == ltEstimatedTime) {
             return (value < m_layers_times.size()) ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : "";
@@ -762,7 +762,7 @@ void Control::draw_ticks_pair(wxDC& dc, wxCoord pos, wxCoord mid, int tick_len)
         dc.DrawLine(mid - (mid_space + tick_len), pos, mid - mid_space, pos);
     is_horizontal() ? dc.DrawLine(pos, mid + (mid_space + tick_len), pos, mid + mid_space) :
         dc.DrawLine(mid + (mid_space + tick_len), pos, mid + mid_space, pos);
-};
+}
 
 void Control::draw_ticks(wxDC& dc)
 {
@@ -773,8 +773,8 @@ void Control::draw_ticks(wxDC& dc)
     int height, width;
     get_size(&width, &height);
     const wxCoord mid = is_horizontal() ? 0.5*height : 0.5*width;
-    for (auto tick : m_ticks.ticks) {
-        if (tick.tick >= m_values.size()) {
+    for (const TickCode& tick : m_ticks.ticks) {
+        if (size_t(tick.tick) >= m_values.size()) {
             // The case when OnPaint is called before m_ticks.ticks data are updated (specific for the vase mode)
             break;
         }
@@ -927,7 +927,6 @@ void Control::Ruler::update(wxWindow* win, const std::vector<double>& values, do
     auto end_it = count == 1 ? values.end() : values.begin() + lround(values.size() / count);
 
     while (pow < 3) {
-        int tick = 0;
         for (int istep : {1, 2, 5}) {
             double val = (double)istep * std::pow(10,pow);
             auto val_it = std::lower_bound(values.begin(), end_it, val - epsilon());
@@ -970,7 +969,7 @@ void Control::draw_ruler(wxDC& dc)
     dc.SetTextForeground(GREY_PEN.GetColour());
 
     if (m_ruler.long_step < 0)
-        for (int tick = 1; tick < m_values.size(); tick++) {
+        for (size_t tick = 1; tick < m_values.size(); tick++) {
             wxCoord pos = get_position_from_value(tick);
             draw_ticks_pair(dc, pos, mid, 5);
             draw_tick_text(dc, wxPoint(mid, pos), tick);
@@ -986,7 +985,7 @@ void Control::draw_ruler(wxDC& dc)
             }
         };
 
-        double short_tick;
+        double short_tick = std::nan("");
         int tick = 0;
         double value = 0.0;
         int sequence = 0;
@@ -1003,6 +1002,7 @@ void Control::draw_ruler(wxDC& dc)
                     if (m_values[tick] < value)
                         break;
                 // short ticks from the last tick to the end of current sequence
+                assert(! std::isnan(short_tick));
                 draw_short_ticks(dc, short_tick, tick);
                 sequence++;
             }
diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp
index a9e9d6a03..8fac13733 100644
--- a/src/slic3r/GUI/GCodeViewer.cpp
+++ b/src/slic3r/GUI/GCodeViewer.cpp
@@ -1596,8 +1596,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
                 Vec3f prev_up = prev_right.cross(prev_dir);
 
                 Vec3f next_dir = (next - curr).normalized();
-                Vec3f next_right = Vec3f(next_dir[1], -next_dir[0], 0.0f).normalized();
-                Vec3f next_up = next_right.cross(next_dir);
 
                 bool is_right_turn = prev_up.dot(prev_dir.cross(next_dir)) <= 0.0f;
                 float cos_dir = prev_dir.dot(next_dir);
@@ -2671,13 +2669,13 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool
     };
 
     auto is_travel_in_layers_range = [this](size_t path_id, size_t min_id, size_t max_id) {
-        auto is_in_z_range = [](const Path& path, double min_z, double max_z) {
-            auto in_z_range = [min_z, max_z](double z) {
-                return min_z - EPSILON < z && z < max_z + EPSILON;
-            };
-
-            return in_z_range(path.sub_paths.front().first.position[2]) || in_z_range(path.sub_paths.back().last.position[2]);
-        };
+        // auto is_in_z_range = [](const Path& path, double min_z, double max_z) {
+        //     auto in_z_range = [min_z, max_z](double z) {
+        //         return min_z - EPSILON < z && z < max_z + EPSILON;
+        //     };
+        //
+        //     return in_z_range(path.sub_paths.front().first.position[2]) || in_z_range(path.sub_paths.back().last.position[2]);
+        // };
 
         const TBuffer& buffer = m_buffers[buffer_id(EMoveType::Travel)];
         if (path_id >= buffer.paths.size())
@@ -3396,7 +3394,7 @@ void GCodeViewer::render_toolpaths() const
                 {
                 case TBuffer::ERenderPrimitiveType::Point:
                 {
-                    EOptionsColors color;
+                    EOptionsColors color = EOptionsColors(0);
                     switch (buffer_type(i))
                     {
                     case EMoveType::Tool_change:  { color = EOptionsColors::ToolChanges; break; }
@@ -3405,6 +3403,7 @@ void GCodeViewer::render_toolpaths() const
                     case EMoveType::Custom_GCode: { color = EOptionsColors::CustomGCodes; break; }
                     case EMoveType::Retract:      { color = EOptionsColors::Retractions; break; }
                     case EMoveType::Unretract:    { color = EOptionsColors::Unretractions; break; }
+                    default:                      { assert(false); break; }
                     }
                     render_as_points(buffer, static_cast<unsigned int>(j), color, *shader);
                     break;
@@ -4101,6 +4100,7 @@ void GCodeViewer::render_legend() const
             imgui.text(_u8L("Estimated printing time") + " [" + _u8L("Stealth mode") + "]:");
             break;
         }
+        default : { assert(false); break; }
         }
         ImGui::SameLine();
         imgui.text(short_time(get_time_dhms(time_mode.time)));
@@ -4132,6 +4132,7 @@ void GCodeViewer::render_legend() const
             show_mode_button(_L("Show normal mode"), PrintEstimatedTimeStatistics::ETimeMode::Normal);
             break;
         }
+        default : { assert(false); break; }
         }
     }
 
diff --git a/src/slic3r/GUI/GCodeViewer.hpp b/src/slic3r/GUI/GCodeViewer.hpp
index 836014ad3..a4663dc04 100644
--- a/src/slic3r/GUI/GCodeViewer.hpp
+++ b/src/slic3r/GUI/GCodeViewer.hpp
@@ -610,7 +610,7 @@ public:
 
     const BoundingBoxf3& get_paths_bounding_box() const { return m_paths_bounding_box; }
     const BoundingBoxf3& get_max_bounding_box() const { return m_max_bounding_box; }
-    const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); };
+    const std::vector<double>& get_layers_zs() const { return m_layers.get_zs(); }
 
     const SequentialView& get_sequential_view() const { return m_sequential_view; }
     void update_sequential_view_current(unsigned int first, unsigned int last);
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index 0ff2fef80..6332a7837 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -5822,7 +5822,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
         int get_color_idx_for_tool_change(std::vector<CustomGCode::Item>::const_iterator it, const int extruder) const
         {
             const int current_extruder = it->extruder == 0 ? extruder : it->extruder;
-            if (number_tools() == extruders_cnt + 1) // there is no one "M600"
+            if (number_tools() == size_t(extruders_cnt + 1)) // there is no one "M600"
                 return std::min<int>(extruders_cnt - 1, std::max<int>(current_extruder - 1, 0));
 
             auto it_n = it;
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index e144df6d0..085bdb865 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -325,7 +325,7 @@ private:
         size_t cur_len = 0;
 
         wxString longest_sub_string;
-        auto get_longest_sub_string = [longest_sub_string, input](wxString &longest_sub_str, int cur_len, size_t i) {
+        auto get_longest_sub_string = [input](wxString &longest_sub_str, size_t cur_len, size_t i) {
             if (cur_len > longest_sub_str.Len())
                 longest_sub_str = input.SubString(i - cur_len + 1, i);
         };
diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp
index b460ac736..3a1ec46f2 100644
--- a/src/slic3r/GUI/GUI_Preview.cpp
+++ b/src/slic3r/GUI/GUI_Preview.cpp
@@ -496,13 +496,6 @@ void Preview::on_combochecklist_features(wxCommandEvent& evt)
 
 void Preview::on_combochecklist_options(wxCommandEvent& evt)
 {
-    auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) {
-        auto is_flag_set = [](unsigned int flags, unsigned int flag) {
-            return (flags & (1 << flag)) != 0;
-        };
-        return !is_flag_set(flags1, flag) != !is_flag_set(flags2, flag);
-    };
-
     unsigned int curr_flags = m_canvas->get_gcode_options_visibility_flags();
     unsigned int new_flags = Slic3r::GUI::combochecklist_get_flags(m_combochecklist_options);
     if (curr_flags == new_flags)
@@ -513,6 +506,13 @@ void Preview::on_combochecklist_options(wxCommandEvent& evt)
 #if ENABLE_RENDER_PATH_REFRESH_AFTER_OPTIONS_CHANGE
     m_canvas->refresh_gcode_preview_render_paths();
 #else
+    auto xored = [](unsigned int flags1, unsigned int flags2, unsigned int flag) {
+        auto is_flag_set = [](unsigned int flags, unsigned int flag) {
+            return (flags & (1 << flag)) != 0;
+        };
+        return !is_flag_set(flags1, flag) != !is_flag_set(flags2, flag);
+    };
+
     bool skip_refresh = xored(curr_flags, new_flags, static_cast<unsigned int>(OptionType::Shells)) ||
         xored(curr_flags, new_flags, static_cast<unsigned int>(OptionType::ToolMarker));
 
diff --git a/src/slic3r/GUI/InstanceCheck.cpp b/src/slic3r/GUI/InstanceCheck.cpp
index 6cfa879c8..73bbeda35 100644
--- a/src/slic3r/GUI/InstanceCheck.cpp
+++ b/src/slic3r/GUI/InstanceCheck.cpp
@@ -41,7 +41,7 @@ namespace instance_check_internal
 		//if (argc < 2)
 		//	return ret;
 		std::vector<std::string> arguments { argv[0] };
-		for (size_t i = 1; i < argc; ++i) {
+        for (int i = 1; i < argc; ++i) {
 			const std::string token = argv[i];
 			// Processing of boolean command line arguments shall match DynamicConfig::read_cli().
 			if (token == "--single-instance")
@@ -180,7 +180,7 @@ namespace instance_check_internal
 		if ( !checker->IsAnotherRunning() ) */
 		{
 			DBusMessage* msg;
-			DBusMessageIter args;
+            // DBusMessageIter args;
 			DBusConnection* conn;
 			DBusError 		err;
 			dbus_uint32_t 	serial = 0;
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index ae9e58a95..8b4274579 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -2524,7 +2524,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
     const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast<double>(), 1.0) - 2.0 * Vec3d::Ones();
 
 #ifndef AUTOPLACEMENT_ON_LOAD
-    bool need_arrange = false;
+    // bool need_arrange = false;
 #endif /* AUTOPLACEMENT_ON_LOAD */
     bool scaled_down = false;
     std::vector<size_t> obj_idxs;
@@ -2544,7 +2544,7 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
             new_instances.emplace_back(object->add_instance());
 #else /* AUTOPLACEMENT_ON_LOAD */
             // if object has no defined position(s) we need to rearrange everything after loading
-            need_arrange = true;
+            // need_arrange = true;
              // add a default instance and center object around origin
             object->center_around_origin();  // also aligns object to Z = 0
             ModelInstance* instance = object->add_instance();
@@ -3687,9 +3687,8 @@ bool Plater::priv::warnings_dialog()
 	if (current_warnings.empty())
 		return true;
 	std::string text = _u8L("There are active warnings concerning sliced models:") + "\n";
-	bool empt = true;
 	for (auto const& it : current_warnings) {
-		int next_n = it.first.message.find_first_of('\n', 0);
+        size_t next_n = it.first.message.find_first_of('\n', 0);
 		text += "\n";
 		if (next_n != std::string::npos)
 			text += it.first.message.substr(0, next_n);
@@ -5052,6 +5051,10 @@ bool Plater::load_files(const wxArrayString& filenames)
                 load_files(in_paths, false, true);
                 break;
             }
+            case LoadType::Unknown : {
+                assert(false);
+                break;
+            }
             }
 
             return true;
@@ -5925,7 +5928,6 @@ void Plater::force_print_bed_update()
 void Plater::on_activate()
 {
 #if defined(__linux__) || defined(_WIN32)
-    wxWindow *focus_window = wxWindow::FindFocus();
     // Activating the main frame, and no window has keyboard focus.
     // Set the keyboard focus to the visible Canvas3D.
     if (this->p->view3D->IsShown() && wxWindow::FindFocus() != this->p->view3D->get_wxglcanvas())
diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp
index a13924ccb..ed8824a67 100644
--- a/src/slic3r/GUI/PresetComboBoxes.cpp
+++ b/src/slic3r/GUI/PresetComboBoxes.cpp
@@ -759,7 +759,7 @@ void PlaterPresetComboBox::update()
     this->Clear();
     invalidate_selection();
 
-    const Preset* selected_filament_preset;
+    const Preset* selected_filament_preset = nullptr;
     std::string extruder_color;
     if (m_type == Preset::TYPE_FILAMENT)
     {
diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp
index 738d5e435..2b7b3f3d9 100644
--- a/src/slic3r/GUI/Search.cpp
+++ b/src/slic3r/GUI/Search.cpp
@@ -117,12 +117,6 @@ void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type ty
     }
 }
 
-// Wrap a string with ColorMarkerStart and ColorMarkerEnd symbols
-static wxString wrap_string(const wxString& str)
-{
-    return wxString::Format("%c%s%c", ImGui::ColorMarkerStart, str, ImGui::ColorMarkerEnd);
-}
-
 // Mark a string using ColorMarkerStart and ColorMarkerEnd symbols
 static std::wstring mark_string(const std::wstring &str, const std::vector<uint16_t> &matches, Preset::Type type, PrinterTechnology pt)
 {
diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp
index cdd3ebe85..1cb599fc8 100644
--- a/src/slic3r/GUI/Selection.cpp
+++ b/src/slic3r/GUI/Selection.cpp
@@ -2092,7 +2092,7 @@ static bool is_rotation_xy_synchronized(const Vec3d &rot_xyz_from, const Vec3d &
 
 static void verify_instances_rotation_synchronized(const Model &model, const GLVolumePtrs &volumes)
 {
-    for (size_t idx_object = 0; idx_object < model.objects.size(); ++idx_object) {
+    for (int idx_object = 0; idx_object < int(model.objects.size()); ++idx_object) {
         int idx_volume_first = -1;
         for (int i = 0; i < (int)volumes.size(); ++i) {
             if (volumes[i]->object_idx() == idx_object) {
diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp
index b4b38b4bd..cd5183cb3 100644
--- a/src/slic3r/GUI/UnsavedChangesDialog.cpp
+++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp
@@ -989,7 +989,7 @@ wxString UnsavedChangesDialog::get_short_string(wxString full_string)
 {
     int max_len = 30;
     if (full_string.IsEmpty() || full_string.StartsWith("#") || 
-        (full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < max_len))
+        (full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < size_t(max_len)))
         return full_string;
 
     m_has_long_strings = true;
diff --git a/src/slic3r/GUI/fts_fuzzy_match.h b/src/slic3r/GUI/fts_fuzzy_match.h
index 4b474451c..379fd9c74 100644
--- a/src/slic3r/GUI/fts_fuzzy_match.h
+++ b/src/slic3r/GUI/fts_fuzzy_match.h
@@ -62,13 +62,13 @@ namespace fts {
     }
 
     // Public interface
-    static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore) {
+    [[maybe_unused]] static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore) {
         pos_type matches[max_matches + 1]; // with the room for the stopper
         matches[0] = stopper;
         return fuzzy_match(pattern, str, outScore, matches);
     }
 
-    static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore, pos_type * matches) {
+    [[maybe_unused]] static bool fuzzy_match(char_type const * pattern, char_type const * str, int & outScore, pos_type * matches) {
         int recursionCount = 0;
         static constexpr int recursionLimit = 10;
         return fuzzy_internal::fuzzy_match_recursive(pattern, str, outScore, str, nullptr, matches, 0, recursionCount, recursionLimit);
@@ -114,14 +114,15 @@ namespace fts {
         while (*pattern != '\0' && *str != '\0') {
 
         	int  num_matched  = std::towlower(*pattern) == std::towlower(*str) ? 1 : 0;
-        	bool folded_match = false;
-        	if (! num_matched) {
+            // bool folded_match = false;
+
+            if (! num_matched) {
                 wchar_t tmp[4];
                 wchar_t *end = Slic3r::fold_to_ascii(*str, tmp);
                 wchar_t *c = tmp;
                 for (const wchar_t* d = pattern; c != end && *d != 0 && std::towlower(*c) == std::towlower(*d); ++c, ++d);
                 if (c == end) {
-        			folded_match = true;
+                    // folded_match = true;
         			num_matched = end - tmp;
         		}
 	        }
@@ -169,7 +170,7 @@ namespace fts {
         if (matched) {
             static constexpr int sequential_bonus = 15;            // bonus for adjacent matches
             static constexpr int separator_bonus = 10/*30*/;             // bonus if match occurs after a separator
-            static constexpr int camel_bonus = 30;                 // bonus if match is uppercase and prev is lower
+            // static constexpr int camel_bonus = 30;                 // bonus if match is uppercase and prev is lower
             static constexpr int first_letter_bonus = 15;          // bonus if the first letter is matched
 
             static constexpr int leading_letter_penalty = -1/*-5*/;      // penalty applied for every letter in str before the first match