in reply to "Segmentation fault after destroying window"

Hi, Elsewhere I told you that your "bug" is actually a design flaw, where you repeatedly create and destroy the event-loop (mainwindow), in a loop. You are "hoping" that the event loop can recreate another one, before your destroy takes effect. This will depend on the timing going on in the system, and is why you get sporadic results.

So here is an outline of the way to do it ( others may have similar solutions). Basically you need to only create the mainwindow once, then use Dialogs to ask your questions. This way the mainloop will run solid until you hit the exit button.

I only put rudimentary logic into the analyze_results sub, but your should be able to see the way to analyze your results, and ask new questions.

#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::Dialog; my $result = 'Starting'; my $we_top = new MainWindow; my $message = "Cannot see if Segmentation fault\n"; my $count = 1; $we_top->Label ( -text => $message)->pack(); my $count_lab = $we_top->Label ( -textvariable => \$count)->pack(); my $okay_button = $we_top->Button( -text => 'Get Response', -command => [\&get_response, $result] )->pack(); my $exit_button = $we_top->Button( -text => 'Exit', -command => sub {exit} )->pack(); $we_top->MainLoop; ########################################## sub analyze_response { my $answer = shift; if( $answer eq 'Yes' ){ $result = "Continue at count $count ?"; } if( $answer eq 'No' ){ $result = "Rerun ?"; } if( $answer eq 'Cancel' ){ $result = "Cancelled ?"; } } ########################################### sub get_response { my $answer = do_dialog(); $count++; print "$answer\n"; &analyze_response( $answer ); } ####################################### sub do_dialog { my $dlg = $we_top->Dialog( -title=>"Here is a question for you.", -buttons => ["Cancel", "No", "Yes"], -default_button => "No", -text => $result, -font => "Helvetica" ); my $return = $dlg->Show(); return $return; } __END__

I'm not really a human, but I play one on earth. flash japh