Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all,
I have a rather complicated Perl/TK code (which I'm not going to post here
:)
I sometimes get the following error printed when my application ends:
Tk::Error:
("after" script)
Everything works well, but I want at least to understand the meaning of this
error.
Any help ?
TIA,
Oded
Post Follow-up to this messageOn Tue, 13 Dec 2005 14:22:25 +0200, "Oded" <dv@mailtag.com> wrote:
>Hi all,
>
>I have a rather complicated Perl/TK code (which I'm not going to post here
>:)
>I sometimes get the following error printed when my application ends:
>
>Tk::Error:
> ("after" script)
>
>Everything works well, but I want at least to understand the meaning of thi
s
>error.
>
>Any help ?
Yes, it's a commonly seen message, and it means you left an "after" or
"repeat" statement running, when you exited. I'm not sure what is the
exact combinations of widgets that cause it, but this is how to stop it.
What you need to do is name your after statements, and have a safe
exit subroutine, which cancels the statement before exiting.
########################################
#############
my $timer; #global so you can access from anywhere
$timer = $mw->repeat(1000 => sub {$counter ++});
sub clean_exit{
$timer->cancel;
exit;
}
########################################
###############
then you need to call that sub at all exit points, even trying to catch
the window manager's X button with
$mw->protocol( 'WM_DELETE_WINDOW' => \&clean_exit );
Those are the basics. Of course you can get very creative on
stopping your timers, but the above method is the basics.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Post Follow-up to this messageI managed to get rid of this error thanks to your detailed explanation.
Thanks much,
Oded
"zentara" <zentara@highstream.net> wrote in message
news:fuftp1hfu1mh4nv6pppfn59n87g37cropj@
4ax.com...
> On Tue, 13 Dec 2005 14:22:25 +0200, "Oded" <dv@mailtag.com> wrote:
>
here
this
> Yes, it's a commonly seen message, and it means you left an "after" or
> "repeat" statement running, when you exited. I'm not sure what is the
> exact combinations of widgets that cause it, but this is how to stop it.
>
> What you need to do is name your after statements, and have a safe
> exit subroutine, which cancels the statement before exiting.
>
> ########################################
#############
> my $timer; #global so you can access from anywhere
>
> $timer = $mw->repeat(1000 => sub {$counter ++});
>
> sub clean_exit{
> $timer->cancel;
> exit;
> }
> ########################################
###############
>
> then you need to call that sub at all exit points, even trying to catch
> the window manager's X button with
>
> $mw->protocol( 'WM_DELETE_WINDOW' => \&clean_exit );
>
>
> Those are the basics. Of course you can get very creative on
> stopping your timers, but the above method is the basics.
>
>
> --
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.