From 2956c1a2e54600ed9a5db9fc0c12a1d779088707 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 24 Dec 2013 11:58:36 +0100 Subject: [PATCH] More work for removing references to $Slic3r::Config --- lib/Slic3r/Extruder.pm | 6 +++++- lib/Slic3r/Flow.pm | 5 +++-- lib/Slic3r/Print.pm | 7 ++----- t/threads.t | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index d976e715a..9f4cba2b2 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -25,7 +25,11 @@ has '_mm3_per_mm_cache' => (is => 'ro', default => sub {{}}); sub _build_bridge_flow { my $self = shift; - return Slic3r::Flow::Bridge->new(nozzle_diameter => $self->nozzle_diameter); + + return Slic3r::Flow::Bridge->new( + nozzle_diameter => $self->nozzle_diameter, + bridge_flow_ratio => $self->config->bridge_flow_ratio, + ); } sub _build_e_per_mm3 { diff --git a/lib/Slic3r/Flow.pm b/lib/Slic3r/Flow.pm index b4aaad497..a02f7b34e 100644 --- a/lib/Slic3r/Flow.pm +++ b/lib/Slic3r/Flow.pm @@ -90,13 +90,14 @@ use Moo; extends 'Slic3r::Flow'; # layer_height is not required in this case -has '+layer_height' => (is => 'ro', required => 0); +has '+layer_height' => (is => 'ro', required => 0); +has 'bridge_flow_ratio' => (is => 'ro', required => 1); use Slic3r::Geometry qw(PI); sub _build_width { my $self = shift; - return sqrt($Slic3r::Config->bridge_flow_ratio * ($self->nozzle_diameter**2)); + return sqrt($self->bridge_flow_ratio * ($self->nozzle_diameter**2)); } sub _build_spacing { diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 19ea2dce9..83566b1f6 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -39,9 +39,6 @@ sub BUILD { sub init_config { my $self = shift; - # store config in a handy place - $Slic3r::Config = $self->config; - # legacy with existing config files $self->config->set('first_layer_height', $self->config->layer_height) if !$self->config->first_layer_height; @@ -861,7 +858,7 @@ sub write_gcode { } my $buffer = Slic3r::GCode::CoolingBuffer->new( - config => $Slic3r::Config, + config => $self->config, gcodegen => $gcodegen, ); @@ -903,7 +900,7 @@ sub write_gcode { } my $buffer = Slic3r::GCode::CoolingBuffer->new( - config => $Slic3r::Config, + config => $self->config, gcodegen => $gcodegen, ); foreach my $print_z (sort { $a <=> $b } keys %layers) { diff --git a/t/threads.t b/t/threads.t index 420d58f36..106a68af5 100644 --- a/t/threads.t +++ b/t/threads.t @@ -26,10 +26,10 @@ plan tests => 2; { my $thread = threads->create(sub { - # $print can't be inizialized outside the thread because Object->slice will - # modify it by removing meshes and popping layers - my $print = Slic3r::Test::init_print('20mm_cube'); - Slic3r::Test::gcode($print); + { + my $print = Slic3r::Test::init_print('20mm_cube'); + Slic3r::Test::gcode($print); + } Slic3r::thread_cleanup(); return 1; });