Debian Codegraph @

xt/mw_segfault.t

raw
1 #!/usr/bin/perl -w
2
3 # This is an (automated) variation of https://bugzilla.redhat.com/show_bug.cgi?id=235666
4 # It segfaults on FreeBSD 7 with 5.10.0, but not with 5.8.8.
5 #
6 # The reason is an already known problem: destroying a MainWindow
7 # removes some parts of the interpreter which is strictly needed by
8 # subsequent MainWindows.
9
10 use strict;
11
12 use Test::More;
13 plan tests => 1;
14
15 use Tk;
16
17 sub yes_no{
18 my $OKMOD;
19 my $Alerte = MainWindow->new(
20 -title => "Yes or No",
21 );
22
23 my $BMOD = $Alerte->Button(
24 -text => "Yes",
25 -background => "green",
26 -command => sub{$OKMOD = 1; $Alerte->destroy() }
27 )->pack(-side=> 'left', -expand=>1);
28
29 my $BFIN = $Alerte->Button(
30 -text => "No",
31 -background => "red",
32 -command => sub{$OKMOD = 0; $Alerte->destroy() }
33 )->pack(-side=>'left', -expand=>1);
34 $BMOD->afterIdle(sub { $BMOD->invoke });
35 MainLoop;
36 return $OKMOD;
37 }
38
39 my $n = 1000;
40 diag "Creating and destroying $n MainWindows. This may take some time...";
41 for(1..$n) {
42 yes_no('test');
43 }
44 pass 'No segfault';
45
46 __END__