From 99d9c17a4bba1fc7d3722a85c7c1e8aa783d9559 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Mon, 15 Sep 2025 19:56:57 +0200 Subject: [PATCH 1/6] fixes: wxPen::wxPen(const wxColour&, int, int) is deprecated: use wxPENSTYLE_XXX constants [-Wdeprecated-declarations] --- src/slic3r/GUI/Widgets/LabeledStaticBox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Widgets/LabeledStaticBox.cpp b/src/slic3r/GUI/Widgets/LabeledStaticBox.cpp index 93e4596aa5..2723b3f38a 100644 --- a/src/slic3r/GUI/Widgets/LabeledStaticBox.cpp +++ b/src/slic3r/GUI/Widgets/LabeledStaticBox.cpp @@ -160,7 +160,7 @@ void LabeledStaticBox::DrawBorderAndLabel(wxDC& dc) wxSize wSz = GetSize(); dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.SetPen(wxPen(border_color.colorForStates(state_handler.states()), m_border_width, wxSOLID)); + dc.SetPen(wxPen(border_color.colorForStates(state_handler.states()), m_border_width, wxPENSTYLE_SOLID)); dc.DrawRoundedRectangle( // Border std::max(0, m_pos.x), std::max(0, m_pos.y) + m_label_height * .5, @@ -185,4 +185,4 @@ void LabeledStaticBox::GetBordersForSizer(int* borderTop, int* borderOther) cons #ifdef __WXOSX__ *borderOther = 5; // Make sure macOS uses the same border padding as other platforms #endif -} \ No newline at end of file +} From d82e7e50051340839116223101d5b49ddf1359c0 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Mon, 15 Sep 2025 21:05:18 +0200 Subject: [PATCH 2/6] fixes: may be used uninitialized [-Wmaybe-uninitialized] --- src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp index fdc2e0ab0a..c4beb5553c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBrimEars.cpp @@ -208,8 +208,8 @@ bool GLGizmoBrimEars::unproject_on_mesh2(const Vec2d &mouse_pos, std::pairobject_clipper()->get_position(); const ClippingPlane *clp = m_c->object_clipper()->get_clipping_plane(); bool mouse_on_object = false; - Vec3f position_on_model {}; - Vec3f normal_on_model {}; + Vec3f position_on_model { Vec3f::Zero() }; + Vec3f normal_on_model { Vec3f::Zero() }; double closest_hit_distance = std::numeric_limits::max(); for (auto item : m_mesh_raycaster_map) { From 40e573aa6782484f304dd81c0b56d58059041491 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Mon, 15 Sep 2025 21:54:12 +0200 Subject: [PATCH 3/6] =?UTF-8?q?fixes:=20pointer=20used=20after=20=E2=80=98?= =?UTF-8?q?void=20operator=20delete(void*,=20std::size=5Ft)=E2=80=99=20[-W?= =?UTF-8?q?use-after-free]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/slic3r/GUI/ObjectDataViewModel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/ObjectDataViewModel.cpp b/src/slic3r/GUI/ObjectDataViewModel.cpp index a7d2f711bf..a4323c4a83 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.cpp +++ b/src/slic3r/GUI/ObjectDataViewModel.cpp @@ -1048,13 +1048,12 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item) ObjectDataViewModelNode* last_instance_node = node_parent->GetNthChild(0); PrintIndicator last_instance_printable = last_instance_node->IsPrintable(); node_parent->GetChildren().Remove(last_instance_node); - delete last_instance_node; ItemDeleted(parent, wxDataViewItem(last_instance_node)); + delete last_instance_node; ObjectDataViewModelNode* obj_node = node_parent->GetParent(); obj_node->set_printable_icon(last_instance_printable); obj_node->GetChildren().Remove(node_parent); - delete node_parent; ret_item = wxDataViewItem(obj_node); #ifndef __WXGTK__ @@ -1062,6 +1061,7 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item) obj_node->m_container = false; #endif //__WXGTK__ ItemDeleted(ret_item, wxDataViewItem(node_parent)); + delete node_parent; return ret_item; } @@ -1073,7 +1073,6 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item) { ObjectDataViewModelNode* obj_node = node_parent->GetParent(); obj_node->GetChildren().Remove(node_parent); - delete node_parent; ret_item = wxDataViewItem(obj_node); #ifndef __WXGTK__ @@ -1081,6 +1080,7 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item) obj_node->m_container = false; #endif //__WXGTK__ ItemDeleted(ret_item, wxDataViewItem(node_parent)); + delete node_parent; return ret_item; } From 18aee83ca0082c0282f03ac6c0ddbd2e184d282b Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Mon, 15 Sep 2025 23:54:59 +0200 Subject: [PATCH 4/6] fixes: dangling pointer to an unnamed temporary may be used [-Wdangling-pointer=] --- src/libslic3r/SLAPrint.cpp | 4 ++-- src/slic3r/GUI/Selection.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 569d22501e..b50e5233cb 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1182,8 +1182,8 @@ sla::DrainHoles SLAPrintObject::transformed_drainhole_points() const { assert(m_model_object != nullptr); auto pts = m_model_object->sla_drain_holes; - auto tr = trafo().cast(); - auto sc = m_model_object->instances.front()->get_scaling_factor().cast(); + const auto tr = trafo().cast(); + const Vec3f sc = m_model_object->instances.front()->get_scaling_factor().cast(); for (sla::DrainHole &hl : pts) { hl.pos = tr * hl.pos; hl.normal = tr * hl.normal - tr.translation(); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 34063c1ca9..efb8ef87e9 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -3166,7 +3166,7 @@ void Selection::paste_objects_from_clipboard() if (shift_all(0) != 0 || shift_all(1) != 0) { // BBS: if multiple objects are selected, move them as a whole after copy if (i == 0) empty_cell_all = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)}, {bbox.size()(0)+1,bbox.size()(1)+1}); - auto instance_shift = src_object->instances.front()->get_offset() - src_objects[0]->instances.front()->get_offset(); + const Vec3d instance_shift = src_object->instances.front()->get_offset() - src_objects[0]->instances.front()->get_offset(); displacement = {shift_all.x() + empty_cell_all.x() + instance_shift.x(), shift_all.y() + empty_cell_all.y() + instance_shift.y(), start_offset(2)}; } else { // BBS: if only one object is copied, find an empty cell to put it From cff6dd55027a008939f06ba6dd75ebcaf2016bd9 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Sun, 21 Dec 2025 11:38:24 +0100 Subject: [PATCH 5/6] review result part 0: -Wuse-after-free vs wxWidget --- src/slic3r/GUI/ObjectDataViewModel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/ObjectDataViewModel.cpp b/src/slic3r/GUI/ObjectDataViewModel.cpp index a4323c4a83..4f1b40f8b1 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.cpp +++ b/src/slic3r/GUI/ObjectDataViewModel.cpp @@ -1048,8 +1048,12 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item) ObjectDataViewModelNode* last_instance_node = node_parent->GetNthChild(0); PrintIndicator last_instance_printable = last_instance_node->IsPrintable(); node_parent->GetChildren().Remove(last_instance_node); - ItemDeleted(parent, wxDataViewItem(last_instance_node)); delete last_instance_node; + // `delete` before `ItemDeleted()` is valid wxWidget pattern +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuse-after-free" + ItemDeleted(parent, wxDataViewItem(last_instance_node)); +#pragma GCC diagnostic pop ObjectDataViewModelNode* obj_node = node_parent->GetParent(); obj_node->set_printable_icon(last_instance_printable); From 3e27d05c3d48a72293eae14c99180ba3aa53eca7 Mon Sep 17 00:00:00 2001 From: Raoul Rubien Date: Sun, 21 Dec 2025 11:39:43 +0100 Subject: [PATCH 6/6] review result part 1: Transform3f instead of auto --- src/libslic3r/SLAPrint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index b50e5233cb..f2ae09de0f 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -1182,7 +1182,7 @@ sla::DrainHoles SLAPrintObject::transformed_drainhole_points() const { assert(m_model_object != nullptr); auto pts = m_model_object->sla_drain_holes; - const auto tr = trafo().cast(); + const Transform3f tr = trafo().cast(); const Vec3f sc = m_model_object->instances.front()->get_scaling_factor().cast(); for (sla::DrainHole &hl : pts) { hl.pos = tr * hl.pos;