From aa069d90fbc7ba66c08add00bd684068828ab922 Mon Sep 17 00:00:00 2001 From: TheLegendTubaGuy <95944177+thelegendtubaguy@users.noreply.github.com> Date: Mon, 26 Oct 2026 07:46:30 -0500 Subject: [PATCH] Fix plates keeping stale objects after a cut (#16881) The cut and "Delete all connectors" removed objects without telling the plates, so the plates kept counting objects by their old index. Prime tower previews showed another plate's filaments, and Select All picked up objects from other plates. Removing a whole object now also removes every instance of it from the plates, not just the first one. --- src/slic3r/GUI/GUI_ObjectList.cpp | 1 + src/slic3r/GUI/PartPlate.cpp | 13 +++++++++++++ src/slic3r/GUI/Plater.cpp | 1 + 3 files changed, 15 insertions(+) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 5961d5af47..f0519d2380 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -3653,6 +3653,7 @@ void ObjectList::delete_all_connectors_for_object(int obj_idx) if (obj->volumes.empty() || !obj->has_solid_mesh()) { const std::string deleted_obj_name = obj->name; model.delete_object(idx); + wxGetApp().plater()->get_partplate_list().notify_instance_removed(idx, -1); { Slic3r::LifecycleEventContext ctx; ctx.name = deleted_obj_name; diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 584bb763ba..f0d4f3f6c6 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -7402,6 +7402,19 @@ int PartPlateList::notify_instance_removed(int obj_id, int instance_id) } if (instance_id == -1) { + // The object's other instances go with it, and may sit on other plates: left in place, + // update_object_index below would renumber them onto the previous object. + std::set other_instances; + for (PartPlate* p : m_plate_list) + for (const std::pair& obj_inst : p->obj_to_instance_set) + if (obj_inst.first == obj_id) + other_instances.insert(obj_inst.second); + for (const std::pair& obj_inst : unprintable_plate.obj_to_instance_set) + if (obj_inst.first == obj_id) + other_instances.insert(obj_inst.second); + for (int other_instance : other_instances) + notify_instance_removed(obj_id, other_instance); + //update all the obj_ids which is bigger for (unsigned int i = 0; i < (unsigned int)m_plate_list.size(); ++i) { diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index edf9e13649..fa1c4944d1 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -19471,6 +19471,7 @@ void Plater::convert_unit(ConversionType conv_type) void Plater::apply_cut_object_to_model(size_t obj_idx, const ModelObjectPtrs& new_objects) { model().delete_object(obj_idx); + p->partplate_list.notify_instance_removed(obj_idx, -1); sidebar().obj_list()->delete_object_from_list(obj_idx); // suppress to call selection update for Object List to avoid call of early Gizmos on/off update