Just in case, I'll show you a visual representation (and also because I originally thought this would make things more clear):
Now it's clear that (some IDs) in the picture disappears (when $ptext goes out of scope at the end of the subroutine), and never gets pushed into the intended array $pboard->{'text'} (so the Canvas text is never successfully deleted).+ + Code / Comments Visually ====================================================================== +======== my $ptext = $pboard->{'text'}; pboard->text ====+ | v ptext ====> [ (some IDs) ] + + + + $pboard->{'text'} = [ ]; pboard->text ===> [ ] # Now they're pointing to ptext ==========> [ (some IDs) ] # different things + + + + my $id = my_create($canvas, ...); pboard->text ===> [ ] push @$ptext, $id; ptext ===========> [ (some IDs), $i +d ] # But my intent was to add $id to # $pboard->{'text'}!
I'm quite sure from calling show_id_hash() that the Canvas text objects were never getting deleted (even though their numeric IDs were when $ptext went out of scope). And it's also clear to me that the same text objects do get deleted when I correctly reassign $ptext to point to the anonymous array which was assigned to $pboard->{'text'} (or by emptying out the original array with @$ptext = ( )).
Does that make my intent any clearer, or do you still find something amiss?
In reply to Re^2: Adventures in Debugging a Perl/Tk Game (other leak)
by liverpole
in thread Adventures in Debugging a Perl/Tk Game
by liverpole
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |