From: Vincent Pit Date: Wed, 21 Jul 2010 17:33:42 +0000 (+0200) Subject: Globally store layer objects as weak references X-Git-Tag: v0.01~18 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=39ceba3937f8397bcb0874419d78f3c4adc427fb;p=perl%2Fmodules%2FLaTeX-TikZ.git Globally store layer objects as weak references --- diff --git a/Makefile.PL b/Makefile.PL index 5625d46..442433f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -18,8 +18,10 @@ my %PREREQ_PM = ( 'Math::Complex' => 0, 'Math::Trig' => 0, 'Mouse' => '0.63', # register_type_constraint + 'Scalar::Util' => 0, 'Scope::Guard' => 0, 'Sub::Name' => 0, + 'Task::Weaken' => 0, 'constant' => 0, ); diff --git a/lib/LaTeX/TikZ/Mod/Layer.pm b/lib/LaTeX/TikZ/Mod/Layer.pm index 6b3f73d..bfab947 100644 --- a/lib/LaTeX/TikZ/Mod/Layer.pm +++ b/lib/LaTeX/TikZ/Mod/Layer.pm @@ -15,7 +15,8 @@ Version 0.01 our $VERSION = '0.01'; -use List::Util (); +use Scalar::Util (); +use List::Util (); use LaTeX::TikZ::Mod::Formatted; @@ -91,7 +92,9 @@ around 'new' => sub { sub BUILD { my ($self) = @_; - $layers{$self->name} = $self; + my $name = $self->name; + $layers{$name} = $self; + Scalar::Util::weaken($layers{$name}); } sub DEMOLISH {