From 2621f92471eb21f951c2f6880927e9f0c6ec828f Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Wed, 19 Aug 2009 21:37:17 +0000 Subject: [PATCH] Small bug with the memory leak fix... fixed --- lib/WebGUI/AssetLineage.pm | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index ff69f9fe5..659b1d9f1 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -259,8 +259,8 @@ Returns the highest rank, top of the highest rank Asset under current Asset. sub getFirstChild { my $self = shift; - # TODO: Use accessor here instead - unless (exists $self->{_firstChild}) { + my $child = $self->cacheChild('first'); + unless ($child) { my $assetLineage = $self->session->stow->get("assetLineage"); my $lineage = $assetLineage->{firstChild}{$self->getId}; unless ($lineage) { @@ -270,11 +270,10 @@ sub getFirstChild { $self->session->stow->set("assetLineage", $assetLineage); } } - my $child = WebGUI::Asset->newByLineage($self->session,$lineage); + $child = WebGUI::Asset->newByLineage($self->session,$lineage); $self->cacheChild(first => $child); } - # TODO: Use accessor here instead - return $self->{_firstChild}; + return $child; } @@ -288,8 +287,8 @@ Returns the lowest rank, bottom of the lowest rank Asset under current Asset. sub getLastChild { my $self = shift; - # TODO: Use accessor here instead - unless (exists $self->{_lastChild}) { + my $child = $self->cacheChild('last'); + unless ($child) { my $assetLineage = $self->session->stow->get("assetLineage"); my $lineage = $assetLineage->{lastChild}{$self->getId}; unless ($lineage) { @@ -297,11 +296,10 @@ sub getLastChild { $assetLineage->{lastChild}{$self->getId} = $lineage; $self->session->stow->set("assetLineage", $assetLineage); } - my $child = WebGUI::Asset->newByLineage($self->session,$lineage); + $child = WebGUI::Asset->newByLineage($self->session,$lineage); $self->cacheChild(last => $child); } - # TODO: Use accessor here instead - return $self->{_lastChild}; + return $child; } #------------------------------------------------------------------- @@ -787,11 +785,9 @@ Returns 1 or the count of Assets with the same parentId as current Asset's asset sub hasChildren { my $self = shift; unless (exists $self->{_hasChildren}) { - # TODO: Use accessor here instead - if (exists $self->{_firstChild}) { + if ($self->cacheChild('first')) { $self->{_hasChildren} = 1; - # TODO: Use accessor here instead - } elsif (exists $self->{_lastChild}) { + } elsif ($self->cacheChild('last')) { $self->{_hasChildren} = 1; } else { $self->{_hasChildren} = $self->getChildCount;