Subject: | Errors when calling Perl exit from Tk sub |
Using Tcl::pTk 0.95 and Tcl/Tk 8.6.9, but I'm not aware this doesn't apply to earlier Tcl::pTk or Tcl/Tk.
According to Mastering Perl/Tk §1.4.1 "exit Versus destroy", Perl/Tk redefines exit; to my knowledge, Tcl::pTk does not do this. Currently, the File > Quit command in the widgetTclpTk demo invokes sub { exit }. Clicking File > Quit causes the following errors:
- on macOS XQuartz, causes "Segmentation fault 11" (will attach crash log)
- on Fedora 29, causes the following error (only the opcode values are consistent):
X Error of failed request: RenderBadPicture (invalid Picture parameter)
Major opcode of failed request: 138 (RENDER)
Minor opcode of failed request: 7 (RenderFreePicture)
Picture id in failed request: 0x16000e2
Serial number of failed request: 1961
Current serial number in output stream: 2049
- on FreeBSD 13.0 (GhostBSD 18.12, Project Trident PR2), causes "Bus error".
Nothing interesting happens on macOS Aqua or Windows.
Maybe exit should be redefined by Tcl::pTk, but how? Should it just be a shorthand for destroying the main window (…->interp->Eval('destroy .')), or are there enough situations where that shouldn't be what is done?
Though as Mastering Perl/Tk points out, the more clear alternative (and workaround for this issue) is to just use $MW->destroy instead of exit.