From 178760dea68526879d3fe3b30bf7d8ea4cd557be Mon Sep 17 00:00:00 2001 From: Maarten Vanraes Date: Mon, 23 Nov 2015 21:16:10 +0100 Subject: error in recursive ExtTab: clean up properly --- lib/ManaTools/Shared/GUI/ExtTab.pm | 44 +++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/ManaTools/Shared/GUI') diff --git a/lib/ManaTools/Shared/GUI/ExtTab.pm b/lib/ManaTools/Shared/GUI/ExtTab.pm index 0eb95a7e..4232d7e1 100644 --- a/lib/ManaTools/Shared/GUI/ExtTab.pm +++ b/lib/ManaTools/Shared/GUI/ExtTab.pm @@ -161,7 +161,7 @@ has 'lastItem' => ( ); has 'itemcollection' => ( - is => 'ro', + is => 'rw', isa => 'yui::YItemCollection', init_arg => undef, default => sub { @@ -361,6 +361,33 @@ sub buildItem { #============================================================= +=head2 clearItems + +=head3 INPUT + + $self: this object + +=head3 DESCRIPTION + + clears the tab to prepare for re-adding new items, call finishedItems() afterwards + +=cut + +#============================================================= +sub clearItems { + my $self = shift; + my $items = $self->items(); + + # remove all events before deleting all items + $self->clearEvents(); + + for (my $i = 0; $i < scalar(@{$items}); $i = $i + 1) { + delete $items->[$i]; + } +} + +#============================================================= + =head2 finishedItems =head3 INPUT @@ -376,9 +403,24 @@ sub buildItem { #============================================================= sub finishedItems { my $self = shift; + + # remove all Items before adding + $self->tab->deleteAllItems(); + + # remove all children + $self->tab->deleteChildren(); + + # add items from collection $self->tab->addItems($self->itemcollection); + + # set last item to know the active item my $item = $self->lastItem(); + + # show the current one if there is one $self->buildItem($item) if defined($item); + + # create a new itemcollection for adding new items + $self->itemcollection(new yui::YItemCollection()); } #============================================================= -- cgit v1.2.1