From: Jay Kuri Date: Fri, 26 Jun 2009 14:40:18 +0000 (+0000) Subject: patch to avoid memory leak in subinclude by weakening $c reference X-Git-Tag: 0.07_01~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ab0b6bbd649a6cc393814ccc262184d8e0038b0f;hp=7c937cccd1caf12c59b11f07ee76144f770b3ad8;p=catagits%2FCatalyst-View-Component-SubInclude.git patch to avoid memory leak in subinclude by weakening $c reference --- diff --git a/Changes b/Changes index e6a9cdf..6ec1ac5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Catalyst-View-Component-SubInclude +0.06 + - Weaken $c to avoid a memory leak. + 0.05 Tue Apr 21 19:16:00 2009 - Change attribute constraint from ClassName to Str to fix issue with newer Catalyst versions diff --git a/META.yml b/META.yml index 5706a1a..67deb52 100644 --- a/META.yml +++ b/META.yml @@ -1,25 +1,26 @@ ---- -abstract: 'Use subincludes in your Catalyst views' -author: - - 'Nilson Santos Figueiredo Junior, C<< >>' -distribution_type: module -generated_by: 'Module::Install version 0.77' -license: perl -meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 -name: Catalyst-View-Component-SubInclude -no_index: - directory: - - inc - - t -requires: - Carp: 0 - Catalyst::Plugin::SubRequest: 0 - Catalyst::Runtime: 5.70000 - Moose: 0 - Moose::Role: 0 - namespace::clean: 0 -resources: - license: http://dev.perl.org/licenses/ -version: 0.05 +--- +abstract: 'Use subincludes in your Catalyst views' +author: + - 'Nilson Santos Figueiredo Junior, C<< >>' +distribution_type: module +generated_by: 'Module::Install version 0.79' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Catalyst-View-Component-SubInclude +no_index: + directory: + - inc + - t +requires: + Carp: 0 + Catalyst::Plugin::SubRequest: 0 + Catalyst::Runtime: 5.70000 + Moose: 0 + Moose::Role: 0 + Task::Weaken: 0 + namespace::clean: 0 +resources: + license: http://dev.perl.org/licenses/ +version: 0.06 diff --git a/Makefile.PL b/Makefile.PL index 30d6739..65ea5cb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -11,6 +11,7 @@ requires 'Moose'; requires 'Moose::Role'; requires 'Carp'; requires 'namespace::clean'; +requires 'Task::Weaken'; catalyst; diff --git a/lib/Catalyst/View/Component/SubInclude.pm b/lib/Catalyst/View/Component/SubInclude.pm index e4505e0..50dd2c1 100644 --- a/lib/Catalyst/View/Component/SubInclude.pm +++ b/lib/Catalyst/View/Component/SubInclude.pm @@ -3,6 +3,7 @@ use Moose::Role; use Carp qw/croak/; use namespace::clean qw/croak/; +use Scalar::Util qw/weaken/; =head1 NAME @@ -14,7 +15,7 @@ Version 0.05 =cut -our $VERSION = '0.05'; +our $VERSION = '0.06'; =head1 SYNOPSIS @@ -122,7 +123,9 @@ around 'new' => sub { around 'render' => sub { my $next = shift; my ($self, $c, @args) = @_; - + + weaken $c; + $c->stash->{subinclude} = sub { $self->_subinclude( $c, @_ ) }; $c->stash->{subinclude_using} = sub { $self->_subinclude_using( $c, @_ ) };