Fix crash when selecting an object

issue no. 11
This commit is contained in:
tamasmeszaros 2023-01-10 09:42:53 +01:00
parent 39197ecd2d
commit 7c834de6ab
3 changed files with 17 additions and 2 deletions

View File

@ -7055,5 +7055,18 @@ void GLCanvas3D::GizmoHighlighter::blink()
invalidate();
}
const ModelVolume *get_model_volume(const GLVolume &v, const Model &model)
{
const ModelVolume * ret = nullptr;
if (model.objects.size() < v.object_idx()) {
const ModelObject *obj = model.objects[v.object_idx()];
if (obj->volumes.size() < v.volume_idx())
ret = obj->volumes[v.volume_idx()];
}
return ret;
}
} // namespace GUI
} // namespace Slic3r

View File

@ -1046,6 +1046,8 @@ private:
float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); }
};
const ModelVolume * get_model_volume(const GLVolume &v, const Model &model);
} // namespace GUI
} // namespace Slic3r

View File

@ -1974,8 +1974,8 @@ std::vector<unsigned int> Selection::get_volume_idxs_from_instance(unsigned int
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++i) {
const GLVolume* v = (*m_volumes)[i];
if (pt == ptSLA && v->is_modifier &&
m_model->objects[object_idx]->volumes[i]->is_modifier())
const ModelVolume *mv = get_model_volume(*v, *m_model);
if (pt == ptSLA && v->is_modifier && mv && mv->is_modifier())
continue;
if (v->object_idx() == (int)object_idx && v->instance_idx() == (int)instance_idx)
idxs.push_back(i);