Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^7: Tkx after coderef problem

by Anonymous Monk
on Jun 02, 2018 at 20:50 UTC ( #1215760=note: print w/replies, xml ) Need Help??

in reply to Re^6: Tkx after coderef problem
in thread Tkx after coderef problem

That code generates no subroutine. Eliminate the doubts. Identify the exact line that fails in the subroutine. If you need to wrap the entire sub in eval to get something more than the generic failed to callback . You have three calls to after.

Replies are listed 'Best First'.
Re^8: Tkx after coderef problem
by huck (Parson) on Jun 02, 2018 at 21:42 UTC

    "That code generates no subroutine"

    That statement generates the actual callback, it is quite clear the subroutine to callback resides at $tkxfsr->{after}{$afterid}{sub} and that the anonymous subroutine was created by

    $tkxfsr->{after}{$afterid}{sub}=sub{ return unless ($tkxfsr->{after} && $tkxfsr->{after} +{$afterid} && $tkxfsr->{after}{$afterid}{q}); if (scalar(@{$tkxfsr->{after}{$afterid}{q}})) { accept_out_cclose_after($tkxfsr,$afterid,int(ra +nd(2000))); my $msg=shift @{$tkxfsr->{after}{$afterid}{q}}; + print 'LIST '.$msg."\n"; } else { print 'DONE '.$id.' 0'."\n"; delete $tkxfsr->{after}{$afterid}; } };
    As was noted in "debug modification" section at Re^2: Tkx after coderef problem the routine itself functions not as a mere callback but also in a standalone call, so that i why why you confused me whey you asked about the callback. Now in $send_id=Tkx::after( $delay , sub{&{$tkxfsr->{after}{$afterid}{sub}}()}); i might consider the sub{...} as the callback because it is an anonymous subroutine only created by the Tkx::after call and discarded when the after call is canceled or has signaled execution and disposed(destroyed?) its reference. But still the "callback" is the link back, not the subroutine code itself.

    "Eliminate the doubts."

    I have eliminated many of them so far, yet you have yet to offer anything of subsistence to the quest sofar.

    "Identify the exact line that fails in the subroutine."

    Nothing fails in the subroutine, what the problem is that sometimes tkx::after(Tcl/after actually) barfs all over the floor when trying to call the subroutine passed to Tkx::after as a "static" code reference, Not all the time mind you, just sometimes, and in a unpredictable pattern even.

    "If you need to wrap the entire sub in eval to get something more than the generic failed to callback ."

    Nothing is failing in the sub, wrapping it in an eval will do no good, termination of any active code series after calling Tkx::after. At that point the eval will return, and it will fallback nto the eventloop, the eval wont hangaround for when the delay of Tkx::after has expired and it tries to call the subroutine at its internal callback link. Whatever is going wrong is happening in TK/TCL land, as it seems to have lost the ability to callback a perl subroutine when that callback is to a existing scalar reference rather than to an anonymous one-use subroutine. Yet that same subroutine is still callable later at the same address by the perl routine.

    "You have three calls to after."

    yea, one of the 3 gets called based on the run time arg set by -esub. The one setting the callback to an existing scalar coderef fails, and says it doesnt think the callback reference points to subroutine anymore, even thought that after event was triggered by the exact same call to Tkx::after that has already worked from 1 to 5 times already.

    invalid command name "::perl::CODE(0x96f045c)"
    And only on ubuntu-linux, the same code works fine on windoze.

      Lol. Where is the tkx trace?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1215760]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-10-25 20:16 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.