Code Comments
Programming Forum and web based access to our favorite programming groups.Hello *,
I used $wi_main->destroy() in many scripts to close a Tk application. But in
the script I just prepare I get a strange behaviour:
--- CUT start (heavily boilt down) ---
$wi_main=MainWindow->new;
&buildmainwin;
MainLoop;
sub buildmainwin
{
# some stuff which makes up the window ... then:
$wi_main->repeat(1000,\&cyclictasks);
}
sub cyclictasks
{
# Some condition calculations etc. ...
if($condition==1)
{
$wi_main->destroy();
}
}
--- CUT end ---
Misbehaviour:
As soon as the cyclictasks routine calls destroy, the program terminates
with an error:
1cc5540 is not a hash at c:/tools/perl/site/lib/Tk.pm line 340.
When I close the window manually, I get no error.
Yes, I tried to increase the delay time to be sure that it doesn't overtake
itself - no cure.
What is wrong?
perl -v :
This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2002, Larry Wall
Binary build 805 provided by ActiveState Corp. http://www.ActiveState.com
Built 18:08:02 Feb 4 2003
Cheers,
Detlef.
--
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)
Post Follow-up to this messageSorry, forgot to tell that I rebuild the main window in-between.
I kill all of its content ...
--- CUT start ---
@kids=$wi_main->children();
foreach $kid (@kids)
{
$kid->destroy() if Tk::Exists($kid);
}
--- CUT end ---
... and then fill in some new widgets.
After this process, the destroy produces the error. Before, it works fine.
Does the kill influence the $wi_main itself?
Cheers,
Detlef.
--
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)
Post Follow-up to this messageOn Thu, 25 Nov 2004 10:47:54 +0100, "D. Marxsen"
<detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)> wrote:
>I used $wi_main->destroy() in many scripts to close a Tk application. But i
n
>the script I just prepare I get a strange behaviour:
>
>--- CUT start (heavily boilt down) ---
>
>$wi_main=MainWindow->new;
>&buildmainwin;
>
>MainLoop;
>
>sub buildmainwin
>{
> # some stuff which makes up the window ... then:
> $wi_main->repeat(1000,\&cyclictasks);
>}
>
>sub cyclictasks
>{
> # Some condition calculations etc. ...
> if($condition==1)
> {
> $wi_main->destroy();
> }
>}
>
>--- CUT end ---
>
>Misbehaviour:
>As soon as the cyclictasks routine calls destroy, the program terminates
>with an error:
>
>1cc5540 is not a hash at c:/tools/perl/site/lib/Tk.pm line 340.
>
>When I close the window manually, I get no error.
>Yes, I tried to increase the delay time to be sure that it doesn't overtake
>itself - no cure.
>What is wrong?
I'm not sure what your problem is, but I have seen similar errors and I
needed to cancel the timer before destroying the window.
Maybe:
my $repeater = $wi_main->repeat(1000,\&cyclictasks);
sub cyclictasks
{
# Some condition calculations etc. ...
if($condition==1)
{
$repeater->cancel;
$wi_main->destroy();
}
}
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Post Follow-up to this message"zentara" <zentara@highstream.net> schrieb im Newsbeitrag
news:nsubq01698e0ikd0or6hoairueg40pcpvh@
4ax.com...
> On Thu, 25 Nov 2004 10:47:54 +0100, "D. Marxsen"
> <detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)> wrote:
>
...
> I'm not sure what your problem is, but I have seen similar errors and I
> needed to cancel the timer before destroying the window.
>
> Maybe:
>
> my $repeater = $wi_main->repeat(1000,\&cyclictasks);
>
> sub cyclictasks
> {
> # Some condition calculations etc. ...
> if($condition==1)
> {
> $repeater->cancel;
> $wi_main->destroy();
> }
> }
Hi ...
... I tried that, but, alas, it doesn't remove the error.
I even tried to cancel the repeater before reconstructing the window and
installing it again afterwards: No cure.
I changed "$wi_main->destroy();" to "exit;" now, to circumvent the problem.
I lost the possibility to do anything after the MainLoop but that's not
important in this case.
Anyway, thanks for your suggestions!
Detlef
--
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.