Fixed a bug in selection from the 3D scene.

Steps to the reproduce a crash:
1. In SLA mode add some object with several instances
2. Slice
3. Back to 3Dview scene, select all using Ctrl+A
4. Press "Delete"
This commit is contained in:
YuSanka 2020-07-24 11:21:49 +02:00
parent 2f43c1f3fa
commit fd50c3d262
2 changed files with 8 additions and 6 deletions

View file

@ -2364,8 +2364,9 @@ void ObjectList::del_layers_from_object(const int obj_idx)
bool ObjectList::del_subobject_from_object(const int obj_idx, const int idx, const int type)
{
if (obj_idx == 1000)
// Cannot delete a wipe tower.
assert(idx >= 0);
if (obj_idx == 1000 || idx<0)
// Cannot delete a wipe tower or volume with negative id
return false;
ModelObject* object = (*m_objects)[obj_idx];

View file

@ -1605,10 +1605,11 @@ void Selection::update_type()
if ((*m_volumes)[i]->volume_idx() < 0)
++sla_volumes_count;
}
unsigned int volumes_count = model_volumes_count + sla_volumes_count;
// Note: sla_volumes_count is a count of the selected sla_volumes per object instead of per instance, like a model_volumes_count is
unsigned int instances_count = (unsigned int)model_object->instances.size();
unsigned int selected_instances_count = (unsigned int)m_cache.content.begin()->second.size();
if (volumes_count * instances_count == (unsigned int)m_list.size())
if (model_volumes_count * instances_count + sla_volumes_count == (unsigned int)m_list.size())
{
m_type = SingleFullObject;
// ensures the correct mode is selected
@ -1616,7 +1617,7 @@ void Selection::update_type()
}
else if (selected_instances_count == 1)
{
if (volumes_count == (unsigned int)m_list.size())
if (model_volumes_count + sla_volumes_count == (unsigned int)m_list.size())
{
m_type = SingleFullInstance;
// ensures the correct mode is selected
@ -1639,7 +1640,7 @@ void Selection::update_type()
requires_disable = true;
}
}
else if ((selected_instances_count > 1) && (selected_instances_count * volumes_count == (unsigned int)m_list.size()))
else if ((selected_instances_count > 1) && (selected_instances_count * model_volumes_count + sla_volumes_count == (unsigned int)m_list.size()))
{
m_type = MultipleFullInstance;
// ensures the correct mode is selected