[Jifty-commit] r4718 - in jifty/branches/jquery: lib/Jifty/Web
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon Dec 17 00:38:37 EST 2007
Author: gugod
Date: Mon Dec 17 00:38:35 2007
New Revision: 4718
Modified:
jifty/branches/jquery/ (props changed)
jifty/branches/jquery/lib/Jifty/Web/Menu.pm
Log:
r8529 at GOP (orig r4711): sartak | 2007-12-17 05:27:20 +0800
r49133 at onn: sartak | 2007-12-16 16:27:08 -0500
Fix a real memory leak in Jifty::Web::Menu due to copying a weak reference. Woo!
Modified: jifty/branches/jquery/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/Menu.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Web/Menu.pm Mon Dec 17 00:38:35 2007
@@ -25,14 +25,15 @@
my $package = shift;
my $args = ref($_[0]) eq 'HASH' ? shift @_ : {@_};
-
-
- $args->{'_parent'} ||= delete $args->{'parent'};
- weaken $args->{'_parent'} if $args->{'_parent'};
+ my $parent = delete $args->{'parent'};
# Class::Accessor only wants a hashref;
- $package->SUPER::new( $args);
+ my $self = $package->SUPER::new( $args);
+
+ # make sure our reference is weak
+ $self->parent($parent) if defined $parent;
+ return $self;
}
@@ -45,20 +46,19 @@
=head2 parent [MENU]
Gets or sets the parent L<Jifty::Web::Menu> of this item; this defaults
-to null.
+to null. This ensures that the reference is weakened.
=cut
sub parent {
my $self = shift;
- my $parent;
if (@_) {
- $parent = shift;
- weaken $parent;
+ $self->_parent(@_);
+ weaken $self->{_parent};
}
- return $self->_parent($parent);
+ return $self->_parent;
}
More information about the Jifty-commit
mailing list