Reduced memory leaks in ConfigDef / PrintConfigDef

Deleted unsafe default copy constructors / operators in Model / ModelObject / ModelInstance / ModelVolume
Fixed some issues with copying the Model / ModelObject / ModelInstance / ModelVolume inside Print::apply()
Fixed some invalidation issues in Print::apply()
Temporarily renamed the Slic3rPE profile directory to Slic3rPE-alpha.
This commit is contained in:
bubnikv 2018-10-30 15:24:36 +01:00
parent 63960dfde0
commit 66e97aa4eb
7 changed files with 67 additions and 34 deletions
src/libslic3r

View file

@ -483,30 +483,10 @@ void Model::reset_auto_extruder_id()
s_auto_extruder_id = 1;
}
ModelObject::ModelObject(Model *model, const ModelObject &other, bool copy_volumes) :
ModelBase(other), // copy the id
name(other.name),
input_file(other.input_file),
instances(),
volumes(),
config(other.config),
sla_support_points(other.sla_support_points),
layer_height_ranges(other.layer_height_ranges),
layer_height_profile(other.layer_height_profile),
layer_height_profile_valid(other.layer_height_profile_valid),
origin_translation(other.origin_translation),
m_bounding_box(other.m_bounding_box),
m_bounding_box_valid(other.m_bounding_box_valid),
ModelObject::ModelObject(Model *model, const ModelObject &rhs, bool copy_volumes) :
m_model(model)
{
if (copy_volumes) {
this->volumes.reserve(other.volumes.size());
for (ModelVolume *model_volume : other.volumes)
this->add_volume(*model_volume);
}
this->instances.reserve(other.instances.size());
for (const ModelInstance *model_instance : other.instances)
this->add_instance(*model_instance);
this->assign(&rhs, copy_volumes);
}
ModelObject::~ModelObject()
@ -522,6 +502,34 @@ ModelObject* ModelObject::clone(Model *parent)
return new ModelObject(parent, *this, true);
}
ModelObject& ModelObject::assign(const ModelObject *rhs, bool copy_volumes)
{
m_id = rhs->m_id;
name = rhs->name;
input_file = rhs->input_file;
config = rhs->config;
sla_support_points = rhs->sla_support_points;
layer_height_ranges = rhs->layer_height_ranges;
layer_height_profile = rhs->layer_height_profile;
layer_height_profile_valid = rhs->layer_height_profile_valid;
origin_translation = rhs->origin_translation;
m_bounding_box = rhs->m_bounding_box;
m_bounding_box_valid = rhs->m_bounding_box_valid;
volumes.clear();
instances.clear();
if (copy_volumes) {
this->volumes.reserve(rhs->volumes.size());
for (ModelVolume *model_volume : rhs->volumes)
this->add_volume(*model_volume);
this->instances.reserve(rhs->instances.size());
for (const ModelInstance *model_instance : rhs->instances)
this->add_instance(*model_instance);
}
return *this;
}
ModelVolume* ModelObject::add_volume(const TriangleMesh &mesh)
{
ModelVolume* v = new ModelVolume(this, mesh);