Skip Menu |

This queue is for tickets about the MooseX-POE CPAN distribution.

Report information
The Basics
Id: 67049
Status: open
Priority: 0/
Queue: MooseX-POE

People
Owner: Nobody in particular
Requestors: CVENTERS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.211
Fixed in: (no value)



Subject: make_immutable breaks methods using _call_kernel_from_my_session
When __PACKAGE__->meta->make_immutable; is called from a module using MooseX::POE (as is recommended by Moose Best Practices), the "new" method provided by MooseX::POE::Meta::Trait::Object to replace the default Moose-provided constructor will not be executed any longer. It seems that MooseX::POE::Meta::Trait::Constructor partially implements the behavior needed for MooseX::POE to function after make_immutable. A functional POE session is created and START methods are called as expected. However, this method of POE session creation does not register a hook for _call_kernel_from_my_session, which turns all the various helper methods defined by MooseX::POE::Meta::Trait::Object into no-ops. I have attached a test case which should say "test" every second. It exits immediately. If make_immutable is commented out, it works.
Subject: moosex-poe-make-immutable.pl
{ package mxp; use MooseX::POE; sub START { $_[0]->delay('test', 1); } event 'test' => sub { print STDERR "test\n"; $_[0]->delay('test', 1); }; __PACKAGE__->meta->make_immutable; }; { package main; use POE; my $mxp = mxp->new; POE::Kernel->run; }; 1;
What about this patch? This registers _child, _parent and _call_kernel_from_my_session if the MooseX::POE instance is constructed by the constructor built in MooseX::POE::Meta::Trait::Constructor.
Subject: MooseX-POE-consistently-register-events.patch
diff --git a/lib/MooseX/POE/Meta/Trait/Constructor.pm b/lib/MooseX/POE/Meta/Trait/Constructor.pm index 6d02b21..957c0f0 100644 --- a/lib/MooseX/POE/Meta/Trait/Constructor.pm +++ b/lib/MooseX/POE/Meta/Trait/Constructor.pm @@ -16,6 +16,9 @@ around _generate_instance => sub { my %events = $self->associated_metaclass->get_all_events; $events{STARTALL} = 'STARTALL'; $events{_stop} = 'STOPALL'; + $events{_child} = 'CHILD'; + $events{_parent} = 'PARENT'; + $events{_call_kernel_with_my_session} = '_call_kernel_with_my_session'; my $events = join(', ', map { s/'/\\'/g;