fix wekened, add missing test.
Marcus Ramberg [Sun, 23 Apr 2006 19:30:37 +0000 (19:30 +0000)]
Changes
MANIFEST
META.yml
lib/Catalyst/View/TT.pm
t/08cycle.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 8c6f0dc..9610ccb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,7 +1,9 @@
 Revision history for Perl extension Catalyst::View::TT.
 
-0.22   Fri Dec 16 18:25:00 2005
+0.23   Sun Mar 23 20:45:00 2006
        - Added render suport. (Ash Berlin)
+
+0.22   Fri Jan 16 18:25:00 2006
        - stringify $c->action for automatic template match instead of $c->req->action.
          * NOTE * This will change the match to the private name of the matched action! if you
          use template_suffix you have to move your templates around!
index 0ace99f..4f3bdbb 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -13,6 +13,7 @@ t/04pkgconfig.t
 t/05appconfig.t
 t/06includepath.t
 t/07render.t
+t/08cycle.t
 t/lib/TestApp.pm
 t/lib/TestApp/root/specified_template.tt
 t/lib/TestApp/root/test.tt
index 0759ccd..df1d7a9 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Catalyst-View-TT
-version:      0.22
+version:      0.23
 version_from: lib/Catalyst/View/TT.pm
 installdirs:  site
 requires:
index 3fee7e3..4610c80 100644 (file)
@@ -6,7 +6,7 @@ use Template;
 use Template::Timer;
 use NEXT;
 
-our $VERSION = '0.22';
+our $VERSION = '0.23';
 
 __PACKAGE__->mk_accessors('template');
 __PACKAGE__->mk_accessors('include_path');
@@ -360,8 +360,12 @@ sub new {
     # Creation of template outside of call to new so that we can pass [ $self ]
     # as INCLUDE_PATH config item, which then gets ->paths() called to get list
     # of include paths to search for templates.
+   
+    # Use a weakend copy of self so we dont have loops preventing GC from working
+    my $copy = $self;
+    Scalar::Util::weaken($copy);
+    $config->{INCLUDE_PATH} = [ sub { $copy->paths } ];
     
-    $config->{INCLUDE_PATH} = [ $self ];
     $self->{template} = 
         Template->new($config) || do {
             my $error = Template->error();
diff --git a/t/08cycle.t b/t/08cycle.t
new file mode 100644 (file)
index 0000000..ea41a72
--- /dev/null
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+use Test::More;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+plan tests => 3;
+
+use_ok('Catalyst::View::TT');
+use_ok('Catalyst::Test', 'TestApp');
+
+my $copy;
+{
+    my $view = new Catalyst::View::TT("TestApp", {});
+
+    # Can't Test::Memory::Cycle test since it doesn't detect 
+    #  [ sub { $copy->paths } ]
+    # as a cycle, but the above does prevent it getting garbage collected.
+    #
+    # memory_cycle_ok($view, 'No cycles in View');
+
+    $copy = $view;
+    Scalar::Util::weaken($copy);
+}
+
+ok(!defined $copy, 'Copy went out of scope');
+