From: Matt S Trout Date: Sat, 22 Apr 2006 16:29:28 +0000 (+0000) Subject: cycle tests and a weaken call X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a917fb06c55daf3283effbd3857f41e7e077c695;p=dbsrgits%2FDBIx-Class-Historic.git cycle tests and a weaken call --- diff --git a/Changes b/Changes index 0d1e740..8efad83 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for DBIx::Class +0.06003 + - added memory cycle tests and a long-needed weaken call + 0.06002 2006-04-20 00:42:41 - fix set_from_related to accept undef - fix to Dumper-induced hash iteration bug diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 56e002b..9105477 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; +use Scalar::Util qw/weaken/; use base qw/DBIx::Class/; @@ -94,6 +95,7 @@ sub register_source { $reg{$moniker} = $source; $self->source_registrations(\%reg); $source->schema($self); + weaken($source->{schema}) if ref($self); if ($source->result_class) { my %map = %{$self->class_mappings}; $map{$source->result_class} = $moniker; diff --git a/t/52cycle.t b/t/52cycle.t new file mode 100644 index 0000000..0c1e330 --- /dev/null +++ b/t/52cycle.t @@ -0,0 +1,23 @@ +use strict; +use warnings; +use Test::More; + +use lib qw(t/lib); + +BEGIN { + eval { require Test::Memory::Cycle }; + if ($@) { + plan skip_all => "leak test needs Test::Memory::Cycle"; + } else { + plan tests => 1; + } +} + +use DBICTest; +use DBICTest::Schema; + +import Test::Memory::Cycle; + +my $s = DBICTest::Schema->clone; + +memory_cycle_ok($s, 'No cycles in schema');