Don't transfer ownership of Model to Print::Object
This commit is contained in:
parent
13af16ea24
commit
093d1cbe2f
6 changed files with 10 additions and 15 deletions
|
@ -413,7 +413,7 @@ sub load_model_objects {
|
|||
}
|
||||
|
||||
$self->{print}->auto_assign_extruders($o);
|
||||
$self->{print}->add_model_object($self->{model}, $o);
|
||||
$self->{print}->add_model_object($o);
|
||||
}
|
||||
|
||||
# if user turned autocentering off, automatic arranging would disappoint them
|
||||
|
@ -547,7 +547,7 @@ sub rotate {
|
|||
|
||||
# update print
|
||||
$self->{print}->delete_object($obj_idx);
|
||||
$self->{print}->add_model_object($self->{model}, $model_object, $obj_idx);
|
||||
$self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
$object->transform_thumbnail($self->{model}, $obj_idx);
|
||||
}
|
||||
|
@ -583,8 +583,7 @@ sub changescale {
|
|||
|
||||
# update print
|
||||
$self->{print}->delete_object($obj_idx);
|
||||
$self->{print}->add_model_object($self->{model},
|
||||
$model_object, $obj_idx);
|
||||
$self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
$object->transform_thumbnail($self->{model}, $obj_idx);
|
||||
}
|
||||
|
|
|
@ -104,9 +104,8 @@ sub apply_config {
|
|||
if ($rearrange_regions) {
|
||||
# the current subdivision of regions does not make sense anymore.
|
||||
# we need to remove all objects and re-add them
|
||||
my @models_objects = map [$_->model, $_->model_object], @{$self->objects};
|
||||
$self->clear_objects;
|
||||
$self->add_model_object(@$_) for @models_objects;
|
||||
$self->add_model_object($_->model_object) for @{$self->objects};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +120,7 @@ sub has_support_material {
|
|||
# and have explicit instance positions
|
||||
sub add_model_object {
|
||||
my $self = shift;
|
||||
my ($model, $object, $obj_idx) = @_;
|
||||
my ($object, $obj_idx) = @_;
|
||||
|
||||
my $object_config = $object->config->clone;
|
||||
$object_config->normalize;
|
||||
|
@ -170,7 +169,6 @@ sub add_model_object {
|
|||
# initialize print object
|
||||
my $o = Slic3r::Print::Object->new(
|
||||
print => $self,
|
||||
model => $model, # for strong ref
|
||||
model_object => $object,
|
||||
region_volumes => [ map $volumes{$_}, 0..$#{$self->regions} ],
|
||||
copies => [ map Slic3r::Point->new_scale(@{ $_->offset }), @{ $object->instances } ],
|
||||
|
@ -221,9 +219,9 @@ sub reload_object {
|
|||
# For now we just re-add all objects since we haven't implemented this incremental logic yet.
|
||||
# This should also check whether object volumes (parts) have changed.
|
||||
|
||||
my @models_objects = map [$_->model, $_->model_object], @{$self->objects};
|
||||
my @models_objects = map $_->model_object, @{$self->objects};
|
||||
$self->clear_objects;
|
||||
$self->add_model_object(@$_) for @models_objects;
|
||||
$self->add_model_object($_) for @models_objects;
|
||||
}
|
||||
|
||||
sub validate {
|
||||
|
|
|
@ -10,8 +10,7 @@ use Slic3r::Print::State ':steps';
|
|||
use Slic3r::Surface ':types';
|
||||
|
||||
has 'print' => (is => 'ro', weak_ref => 1, required => 1);
|
||||
has 'model' => (is => 'ro', required => 1); # for strong ref so model subobjects are kept in memory
|
||||
has 'model_object' => (is => 'ro', required => 1);
|
||||
has 'model_object' => (is => 'ro', required => 1); # caller is responsible for holding the Model object
|
||||
has 'region_volumes' => (is => 'rw', default => sub { [] }); # by region_id
|
||||
has 'copies' => (is => 'ro'); # Slic3r::Point objects in scaled G-code coordinates
|
||||
has 'config' => (is => 'ro', default => sub { Slic3r::Config::PrintObject->new });
|
||||
|
|
|
@ -67,7 +67,7 @@ sub set_model {
|
|||
|
||||
foreach my $model_object (@{$model->objects}) {
|
||||
$self->_print->auto_assign_extruders($model_object);
|
||||
$self->_print->add_model_object($model, $model_object);
|
||||
$self->_print->add_model_object($model_object);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ sub init_print {
|
|||
$model->center_instances_around_point($print->config->print_center);
|
||||
foreach my $model_object (@{$model->objects}) {
|
||||
$print->auto_assign_extruders($model_object);
|
||||
$print->add_model_object($model, $model_object);
|
||||
$print->add_model_object($model_object);
|
||||
}
|
||||
}
|
||||
$print->validate;
|
||||
|
|
|
@ -172,7 +172,6 @@ if (@ARGV) { # slicing from command line
|
|||
|
||||
$sprint->apply_config($config);
|
||||
$sprint->set_model($model);
|
||||
undef $model; # free memory
|
||||
|
||||
if ($opt{export_svg}) {
|
||||
$sprint->export_svg;
|
||||
|
|
Loading…
Reference in a new issue