Mercurial > pub > Impl
diff Lib/IMPL/Web/View/TTDocument.pm @ 290:7b0dad6117d5
*TTView: fixed memory leak
author | sergey |
---|---|
date | Wed, 20 Feb 2013 17:24:57 +0400 |
parents | 85572f512abc |
children | 5d14baa35790 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm Wed Feb 20 02:25:30 2013 +0400 +++ b/Lib/IMPL/Web/View/TTDocument.pm Wed Feb 20 17:24:57 2013 +0400 @@ -48,14 +48,20 @@ my %controls; my $require; my $documentContext; + + my $self = $this; + $require = sub { my $control = shift; + + carp("Cant load control $control outside the rendering procedure") unless $self; + if (my $factory = $controls{$control}) { return $factory; } else { my $path = $control; - if ( my $template = $this->loader->template($path) ) { + if ( my $template = $self->loader->template($path) ) { $factory = new IMPL::Web::View::TTFactory( $template->class || TTControl, @@ -81,10 +87,9 @@ $this->context->localise(); $documentContext = _clone_context( $this->context ); - my $self = $this; - weaken($self); + $this->context->stash->set(require => $require); - #$this->context->stash->set(document => sub { $self }); + $this->context->stash->set(document => sub { $self }); my $text = eval { @@ -120,6 +125,7 @@ undef $require; undef $documentContext; undef %controls; + undef $self; $this->context->delocalise();