Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

$MainWindow->destroy() causes hash error
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)



Report this thread to moderator Post Follow-up to this message
Old Post
D. Marxsen
11-25-04 01:59 PM


Re: $MainWindow->destroy() causes hash error
Sorry, 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)



Report this thread to moderator Post Follow-up to this message
Old Post
D. Marxsen
11-25-04 01:59 PM


Re: $MainWindow->destroy() causes hash error
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
zentara
11-25-04 08:56 PM


Re: $MainWindow->destroy() causes hash error
"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)



Report this thread to moderator Post Follow-up to this message
Old Post
D. Marxsen
11-26-04 02:02 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:56 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.