From: gfx Date: Wed, 10 Feb 2010 08:13:50 +0000 (+0900) Subject: Support the global destruction flag in DEMOLISH() X-Git-Tag: 0.50_01~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6514735e9b5d79f955badf9f50970ee768a44337;p=gitmo%2FMouse.git Support the global destruction flag in DEMOLISH() --- diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 1d08ac0..d083a6b 100644 --- a/lib/Mouse/Meta/Method/Destructor.pm +++ b/lib/Mouse/Meta/Method/Destructor.pm @@ -13,7 +13,8 @@ sub _generate_destructor{ my $demolishall = ''; for my $class ($metaclass->linearized_isa) { if (Mouse::Util::get_code_ref($class, 'DEMOLISH')) { - $demolishall .= "${class}::DEMOLISH(\$self);\n"; + $demolishall .= sprintf "%s::DEMOLISH(\$self, \$Mouse::Util::in_global_destruction);\n", + $class, } } diff --git a/lib/Mouse/PurePerl.pm b/lib/Mouse/PurePerl.pm index f6c5e5b..802289d 100644 --- a/lib/Mouse/PurePerl.pm +++ b/lib/Mouse/PurePerl.pm @@ -627,7 +627,7 @@ sub DESTROY { my $demolish = Mouse::Util::get_code_ref($class, 'DEMOLISH') || next; - $self->$demolish(); + $self->$demolish($Mouse::Util::in_global_destruction); } }; $@; diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 34ba351..86b7896 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -650,6 +650,7 @@ CODE: PUSHMARK(SP); XPUSHs(object); + XPUSHs(boolSV(PL_dirty)); PUTBACK; call_sv(AvARRAY(demolishall)[i], G_VOID | G_EVAL);