patch to avoid memory leak in subinclude by weakening $c reference
Jay Kuri [Fri, 26 Jun 2009 14:40:18 +0000 (14:40 +0000)]
Changes
META.yml
Makefile.PL
lib/Catalyst/View/Component/SubInclude.pm

diff --git a/Changes b/Changes
index e6a9cdf..6ec1ac5 100644 (file)
--- 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
index 5706a1a..67deb52 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,25 +1,26 @@
----\r
-abstract: 'Use subincludes in your Catalyst views'\r
-author:\r
-  - 'Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>'\r
-distribution_type: module\r
-generated_by: 'Module::Install version 0.77'\r
-license: perl\r
-meta-spec:\r
-  url: http://module-build.sourceforge.net/META-spec-v1.4.html\r
-  version: 1.4\r
-name: Catalyst-View-Component-SubInclude\r
-no_index:\r
-  directory:\r
-    - inc\r
-    - t\r
-requires:\r
-  Carp: 0\r
-  Catalyst::Plugin::SubRequest: 0\r
-  Catalyst::Runtime: 5.70000\r
-  Moose: 0\r
-  Moose::Role: 0\r
-  namespace::clean: 0\r
-resources:\r
-  license: http://dev.perl.org/licenses/\r
-version: 0.05\r
+---
+abstract: 'Use subincludes in your Catalyst views'
+author:
+  - 'Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>'
+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
index 30d6739..65ea5cb 100644 (file)
@@ -11,6 +11,7 @@ requires 'Moose';
 requires 'Moose::Role';
 requires 'Carp';
 requires 'namespace::clean';
+requires 'Task::Weaken';
 
 catalyst;
 
index e4505e0..50dd2c1 100644 (file)
@@ -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, @_ ) };