Cut: Deallocate memory when the gizmo is turned off

This commit is contained in:
Lukas Matena 2023-04-27 12:15:19 +02:00
parent ab0ade0539
commit 0e1d43322c
2 changed files with 8 additions and 0 deletions

View File

@ -905,6 +905,13 @@ void GLGizmoCut3D::on_set_state()
m_selected.clear(); m_selected.clear();
m_parent.set_use_color_clip_plane(false); m_parent.set_use_color_clip_plane(false);
m_c->selection_info()->set_use_shift(false); m_c->selection_info()->set_use_shift(false);
// Make sure that the part selection data are released when the gizmo is closed.
// The CallAfter is needed because in perform_cut, the gizmo is closed BEFORE
// the cut is performed (because of undo/redo snapshots), so the data would
// be deleted prematurely.
if (m_part_selection.valid())
wxGetApp().CallAfter([this]() { m_part_selection = PartSelection(); });
} }
} }

View File

@ -143,6 +143,7 @@ class GLGizmoCut3D : public GLGizmoBase
public: public:
PartSelection() = default; PartSelection() = default;
PartSelection(const ModelObject* mo, const Transform3d& cut_matrix, int instance_idx, const Vec3d& center, const Vec3d& normal, const CommonGizmosDataObjects::ObjectClipper& oc); PartSelection(const ModelObject* mo, const Transform3d& cut_matrix, int instance_idx, const Vec3d& center, const Vec3d& normal, const CommonGizmosDataObjects::ObjectClipper& oc);
~PartSelection() { m_model.clear_objects(); }
struct Part { struct Part {
GLModel glmodel; GLModel glmodel;