Perl Command Line Interpreter crashing on exit

481 views Asked by At

I have an issue where exiting a Perl Tkx script causes the Perl Command Line Interpreter to crash.

Ex:

use strict;
use warnings;
use Tkx;

my $mw     = Tkx::widget->new('.');
my $button = $mw->new_ttk__button(-text => "Hello", -command => \&main);

Tkx::pack($button);

Tkx::MainLoop;

sub main {
    print "TESTING\n";
    exit 0;
}

This code generates the following output:

Main Window

Clicking the "Hello" button invokes the main() subroutine which prints "TESTING" and then attempts to exit and crashes the Command Line Interpreter:

Error Message

This only seems to be happening with Tkx scripts and will only crash if the program has already entered the MainLoop before calling exit. Does anyone know what is going on here?


Perl version information:

Perl Version

1

There are 1 answers

0
tjwrona On BEST ANSWER

It appears that this issue started when I switched from 64 bit Perl to 32 bit Perl. Switching back to the 64 bit version of Perl solved the problem.

It is worth noting that choroba's solution to destroy the main window using g_destroy before exiting did solve the problem even when running the 32 bit version of Perl. Also it is probably better practice to manually destroy your window before exiting even if Perl can clean it up on its own... you never know what version of Perl someone else trying to run your script might have!