Improving 3MF import: checking for invalid data.

This commit is contained in:
Vojtech Bubnik 2021-02-12 16:46:49 +01:00
parent 2228c5e0bf
commit 9c568a543c

View File

@ -710,6 +710,10 @@ namespace Slic3r {
#endif // ENABLE_RELOAD_FROM_DISK_FOR_3MF #endif // ENABLE_RELOAD_FROM_DISK_FOR_3MF
for (const IdToModelObjectMap::value_type& object : m_objects) { for (const IdToModelObjectMap::value_type& object : m_objects) {
if (object.second >= m_model->objects.size()) {
add_error("Unable to find object");
return false;
}
ModelObject* model_object = m_model->objects[object.second]; ModelObject* model_object = m_model->objects[object.second];
IdToGeometryMap::const_iterator obj_geometry = m_geometries.find(object.first); IdToGeometryMap::const_iterator obj_geometry = m_geometries.find(object.first);
if (obj_geometry == m_geometries.end()) { if (obj_geometry == m_geometries.end()) {
@ -1391,6 +1395,10 @@ namespace Slic3r {
{ {
// deletes all non-built or non-instanced objects // deletes all non-built or non-instanced objects
for (const IdToModelObjectMap::value_type& object : m_objects) { for (const IdToModelObjectMap::value_type& object : m_objects) {
if (object.second >= m_model->objects.size()) {
add_error("Unable to find object");
return false;
}
ModelObject *model_object = m_model->objects[object.second]; ModelObject *model_object = m_model->objects[object.second];
if (model_object != nullptr && model_object->instances.size() == 0) if (model_object != nullptr && model_object->instances.size() == 0)
m_model->delete_object(model_object); m_model->delete_object(model_object);