Skip class unload stuff in global destruction
gfx [Sat, 28 Nov 2009 07:40:39 +0000 (16:40 +0900)]
lib/Mouse/Meta/Module.pm
lib/Mouse/Util.pm

index 93b6f68..8a4ccb9 100755 (executable)
@@ -265,6 +265,8 @@ sub get_method_list {
     sub DESTROY{
         my($self) = @_;
 
+        return if $Mouse::Util::in_global_destruction;
+
         my $serial_id = $self->{anon_serial_id};
 
         return if !$serial_id;
index 2de5935..c3f1f39 100644 (file)
@@ -88,6 +88,8 @@ BEGIN {
     generate_isa_predicate_for('Mouse::Meta::Role'           => 'is_a_metarole');
 }
 
+our $in_global_destruction = 0;
+END{ $in_global_destruction = 1 }
 
 # Moose::Util compatible utilities