Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: weird case of memory corruption?

by perltux (Monk)
on May 12, 2021 at 07:36 UTC ( [id://11132447] : note . print w/replies, xml ) Need Help??


in reply to Re: weird case of memory corruption? -- Tk -textvariable
in thread weird case of memory corruption?

I have never had problems with -textvariable in Labels using nested data structures despite using them frequently, this case is the first, so I think ProgressBar is somehow messing with it (you can see that ProgressBar actually resets the value of $pid{ex1}{val} to the '-from' value despite this not being a documented behaviour).

If you try removing the ProgressBar the behaviour of the -textvariable in the Label will be consistently as expected.

Replies are listed 'Best First'.
Re^3: weird case of memory corruption?
by Discipulus (Canon) on May 12, 2021 at 09:08 UTC
    Hello again,

    you are rigth about -textvariable pointing to a nested val: it works correctly (see also why won't Tk textvariable take a reference to an array element? Tk::Entry not updating when textvariable changes. and perl/Tk Entry widget displays wrong value when -textvariable is shared).

    My dumping using Data::Dump dd method shows, if you uncomment and so use your original code PBar( $tmpbar, \$pid{ex1}->{val}, -30, 70 )->pack(); that sometimes val is undef:

    >perl tkprogressbar.pl val PBar1: -21.5 val PBar2: -30 ("ex1", { as => "temp", val => -30 }) val Labels: -30 ("ex1", { as => "temp", val => -30 }) >perl tkprogressbar.pl val PBar1: -21.5 Use of uninitialized value in concatenation (.) or string at tkprogres +sbar.pl line 39. val PBar2: ("ex1", { as => "temp", val => undef }) Use of uninitialized value in concatenation (.) or string at tkprogres +sbar.pl line 21. val Labels: ("ex1", { as => "temp", val => undef })

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.