From: Stevan Little Date: Sat, 11 Mar 2006 17:13:36 +0000 (+0000) Subject: MOP X-Git-Tag: 0_21~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f6d5412dbdef036fe72a0ec7093ff9bff79b188;p=gitmo%2FClass-MOP.git MOP --- diff --git a/Changes b/Changes index 2f2eecd..e77a868 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension Class-MOP. +0.21 + * Class::MOP::Class + - fixed issue where metaclasses are reaped from + our cache in global destruction, and so are not + available in DESTORY calls + 0.20 Thurs. March 2, 2006 - removed the dependency for Clone since we no longer to deep-cloning by default. diff --git a/examples/C3MethodDispatchOrder.pod b/examples/C3MethodDispatchOrder.pod index 1a0c2a0..bfe0531 100644 --- a/examples/C3MethodDispatchOrder.pod +++ b/examples/C3MethodDispatchOrder.pod @@ -8,7 +8,7 @@ use warnings; use Carp 'confess'; use Algorithm::C3; -our $VERSION = '0.02'; +our $VERSION = '0.03'; use base 'Class::MOP::Class'; @@ -34,10 +34,10 @@ C3MethodDispatchOrder->meta->add_around_method_modifier('initialize' => sub { my $method = $_find_method->($meta, $method_name); (defined $method) || confess "Method ($method_name) not found"; goto &$method; - }); + }) unless $meta->has_method('AUTOLOAD'); $meta->add_method('can' => sub { $_find_method->($_[0]->meta, $_[1]); - }); + }) unless $meta->has_method('can'); return $meta; }); diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 474783b..15468e5 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -9,7 +9,7 @@ use Scalar::Util 'blessed', 'reftype'; use Sub::Name 'subname'; use B 'svref_2object'; -our $VERSION = '0.06'; +our $VERSION = '0.07'; # Self-introspection @@ -44,7 +44,13 @@ sub meta { Class::MOP::Class->initialize(blessed($_[0]) || $_[0]) } my $package_name = $options{':package'}; (defined $package_name && $package_name) || confess "You must pass a package name"; - return $METAS{$package_name} if exists $METAS{$package_name}; + # NOTE: + # return the metaclass if we have it cached, + # and it is still defined (it has not been + # reaped by DESTROY yet, which can happen + # annoyingly enough during global destruction) + return $METAS{$package_name} + if exists $METAS{$package_name} && defined $METAS{$package_name}; $class = blessed($class) || $class; # now create the metaclass my $meta;