From 6997f7f5b506e78adde79abb3436128ea6de1f28 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 5 Dec 2018 10:26:08 +0100 Subject: [PATCH] Fixed crash when deleting sla support points --- src/slic3r/GUI/GLCanvas3D.cpp | 21 +++++++++++++++++---- src/slic3r/GUI/GLGizmo.cpp | 6 +++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 68e12d35b..2701fcea5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1378,11 +1378,24 @@ bool GLCanvas3D::Selection::is_single_full_instance() const if (m_type == SingleFullInstance) return true; - int object_idx = m_valid ? get_object_idx() : -1; - if ((0 <= object_idx) && (object_idx < (int)m_model->objects.size())) - return m_model->objects[object_idx]->volumes.size() == m_list.size(); + if (m_list.empty() || m_volumes->empty()) + return false; - return false; + int object_idx = m_valid ? get_object_idx() : -1; + if (object_idx == -1) + return false; + + int instance_idx = (*m_volumes)[*m_list.begin()]->instance_idx(); + + std::set volumes_idxs; + for (const GLVolume* v : *m_volumes) + { + int volume_idx = v->volume_idx(); + if ((v->object_idx() == object_idx) && (v->instance_idx() == instance_idx) && (volume_idx >= 0)) + volumes_idxs.insert(volume_idx); + } + + return m_model->objects[object_idx]->volumes.size() == volumes_idxs.size(); } bool GLCanvas3D::Selection::is_from_single_object() const diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index b5f78362b..2f39f7d69 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -1768,6 +1768,8 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const G m_starting_center = Vec3d::Zero(); m_old_model_object = m_model_object; m_model_object = model_object; + if (selection.is_empty()) + m_old_instance_id = -1; if ((model_object != nullptr) && selection.is_from_single_instance()) { @@ -2048,8 +2050,10 @@ void GLGizmoSlaSupports::clicked_on_object(const Vec2d& mouse_position) int instance_id = m_parent.get_selection().get_instance_idx(); if (m_old_instance_id != instance_id) { + bool something_selected = (m_old_instance_id != -1); m_old_instance_id = instance_id; - return; + if (something_selected) + return; } if (instance_id == -1) return;