1 # subclass Mail::Thread and use this to workaround a memory leak
2 # Based on the patch in: https://rt.cpan.org/Public/Bug/Display.html?id=22817
4 # Additionally, workaround for a bug where $walk->topmost returns undef:
5 # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913
6 # - https://rt.cpan.org/Ticket/Display.html?id=106498
8 # License differs from the rest of public-inbox (but is compatible):
9 # This library is free software; you can redistribute it and/or modify
10 # it under the same terms as Perl itself.
11 package PublicInbox::Thread;
14 use base qw(Mail::Thread);
16 if ($Mail::Thread::VERSION <= 2.55) {
17 eval q(sub _container_class { 'PublicInbox::Thread::Container' });
20 package PublicInbox::Thread::Container;
23 use base qw(Mail::Thread::Container);
24 use Scalar::Util qw(weaken);
25 sub parent { @_ == 2 ? weaken($_[0]->{parent} = $_[1]) : $_[0]->{parent} }
28 $_[0]->SUPER::topmost || PublicInbox::Thread::CPANRTBug106498->new;
32 # - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=795913
33 # - https://rt.cpan.org/Ticket/Display.html?id=106498
34 package PublicInbox::Thread::CPANRTBug106498;
38 sub new { bless {}, $_[0] }