in reply to Re^2: Getting segfaults when destroying and recreating Tk box
in thread Getting segfaults when destroying and recreating Tk box

I note that if you ever destroy a TopLevel window, you eventually provoke another segmentation fault.

That dosn't sound right. You may have a Tk version that needs patching, or you are doing something weird like trying to access a widget packed in the toplevel, after you destroy the toplevel.

If you want to be happy with Tk, stop using destroy to eliminate windows. To exit gracefully, use plain old "exit" or "Tk::exit", they clean up. If you use $mw->destroy, you may be leaving the calling shell alive. Of course, that may be useful in certain circumstances.

#!/usr/bin/perl -w use Tk; my $mw = MainWindow->new(-title=>"#1"); $mw->Button(-text=>"Destroy Me", -command=> sub { $mw->destroy })->pack; $mw->Button(-text=>"Exit Me", -command=> sub { Tk::exit })->pack; MainLoop; print "ha ha still going\n"; <>;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum