Skip Menu |
 

This queue is for tickets about the Tcl-pTk CPAN distribution.

Report information
The Basics
Id: 125058
Status: resolved
Priority: 0/
Queue: Tcl-pTk

People
Owner: CAC [...] cpan.org
Requestors: CAC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.92
Fixed in: 1.07



Subject: fatal error if '.' in Cascade label
Download (untitled) / with headers
text/plain 3.8k
Depending on whether or not `-menuitems' is used to construct a menubar, creating a cascade with a '.' (period/full stop) anywhere in its label can result in a fatal error like the following: bad window path name ".menu02.m1.import.." at /usr/local/share/perl5/Tcl/pTk/Widget.pm line 332. at /usr/local/share/perl5/Tcl/pTk/MegaWidget.pm line 121. Tcl::pTk::Widget::new("Tcl::pTk::Menu", Tcl::pTk::Menu=HASH(0x55660d15fb28), "Name", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/MegaWidget.pm line 58 Tcl::pTk::Widget::Menu(Tcl::pTk::Menu=HASH(0x55660d15fb28), "Name", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/Menu/Item.pm line 123 Tcl::pTk::Menu::Cascade::PreInit("Tcl::pTk::Menu::Cascade", Tcl::pTk::Menu=HASH(0x55660d15fb28), HASH(0x55660b93bfa8)) called at /usr/local/share/perl5/Tcl/pTk/Menu/Item.pm line 49 Tcl::pTk::Menu::Item::new("Tcl::pTk::Menu::Cascade", Tcl::pTk::Menu=HASH(0x55660d15fb28), "-label", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/MegaWidget.pm line 58 Tcl::pTk::Menu::Cascade(Tcl::pTk::Menu=HASH(0x55660d15fb28), "-label", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/Menu/Item.pm line 153 Tcl::pTk::Menu::Cascade::cascade(Tcl::pTk::Menu::Cascade=ARRAY(0x55660d2bfdd8), "-label", "Import...", "-tearoff", "false") called at /home/osboxes/git/HSW12/Perl/hsw12_gui.pm line 479 hsw12_gui::create_main_window(hsw12_gui=HASH(0x55660b33c7b0)) called at /home/osboxes/git/HSW12/Perl/hsw12_gui.pm line 4578 hsw12_gui::build_gui(hsw12_gui=HASH(0x55660b33c7b0)) called at /home/osboxes/git/HSW12/Perl/hsw12_gui.pm line 358 hsw12_gui::new("hsw12_gui", undef) called at ./hsw12.pl line 71 at /usr/local/share/perl5/Tcl/pTk/MegaWidget.pm line 121. Tcl::pTk::Widget::new("Tcl::pTk::Menu", Tcl::pTk::Menu=HASH(0x55660d15fb28), "Name", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/MegaWidget.pm line 58 Tcl::pTk::Widget::Menu(Tcl::pTk::Menu=HASH(0x55660d15fb28), "Name", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/Menu/Item.pm line 123 Tcl::pTk::Menu::Cascade::PreInit("Tcl::pTk::Menu::Cascade", Tcl::pTk::Menu=HASH(0x55660d15fb28), HASH(0x55660b93bfa8)) called at /usr/local/share/perl5/Tcl/pTk/Menu/Item.pm line 49 Tcl::pTk::Menu::Item::new("Tcl::pTk::Menu::Cascade", Tcl::pTk::Menu=HASH(0x55660d15fb28), "-label", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/MegaWidget.pm line 58 Tcl::pTk::Menu::Cascade(Tcl::pTk::Menu=HASH(0x55660d15fb28), "-label", "Import...", "-tearoff", "false") called at /usr/local/share/perl5/Tcl/pTk/Menu/Item.pm line 153 Tcl::pTk::Menu::Cascade::cascade(Tcl::pTk::Menu::Cascade=ARRAY(0x55660d2bfdd8), "-label", "Import...", "-tearoff", "false") called at /home/osboxes/git/HSW12/Perl/hsw12_gui.pm line 479 hsw12_gui::create_main_window(hsw12_gui=HASH(0x55660b33c7b0)) called at /home/osboxes/git/HSW12/Perl/hsw12_gui.pm line 4578 hsw12_gui::build_gui(hsw12_gui=HASH(0x55660b33c7b0)) called at /home/osboxes/git/HSW12/Perl/hsw12_gui.pm line 358 hsw12_gui::new("hsw12_gui", undef) called at ./hsw12.pl line 71 The above is from a submenu (not top-level) cascade, and without using `-menuitems`: cf. https://github.com/chrstphrchvz/HSW12/blob/b365652fd3dca59a90854aa3f5e1b1e777f2bb63/Perl/hsw12_gui.pm#L476 This can be reproduced with the widget demo: in the `menus` demo, changing a cascade submenu label (e.g. '~Check buttons' to '~Check buttons...') fails, but works for a top-level cascade (e.g. '~File' to '~File...'). However the opposite is observed by modifying `menus2` similarly; a submenu cascade accepts '.' in the label, but the top-level menu will not. A workaround is to remove any '.' from the label.
I found where Perl/Tk would remove any '.' and replace with a single '_' in a cascade's label when creating its menu's path: https://github.com/eserte/perl-tk/blob/e8789fa95e8db98537cd9edd385911a8cd706e46/Tk/Widget.pm#L170-L175

 my $leaf  = delete $args{'Name'};
 if (defined $leaf)
  {
   $leaf =~ s/[^a-z0-9_#]+/_/ig;
   $leaf = lcfirst($leaf);
  }

However this wasn't copied to Tcl::pTk, so I'm still looking for what's replaced it/where something equivalent would go.
Tcl::Tk doesn't seem to be affected by this either (at least from changing its menus.pl and menus2.pl demos), so that's probably another place to look…

On Thu Aug 02 01:34:32 2018, CAC wrote:
> Tcl::Tk doesn't seem to be affected by this either (at least from changing its
> menus.pl and menus2.pl demos), so that's probably another place to look…

This might be simply because (as documented):
Tcl::Tk module will generate an unique name of newly created widget.
Meaning it just does things in a less-interesting way by using paths like .dlgbox14.menu19 rather than trying to reuse whatever's in -label/-text. I don't know if that is a good approach (i.e. Perl/Tk compatible), though what would use the pathname from Perl/Tk anyways? Does it make for more useful error messages? Do special menus like .apple or Help require something more like Tkx syntax?

Finally fixed in 1.07.

I found the spot in Menu.pm where spaces are filtered out of what becomes the pathname for a Cascade's menu, and that was a good enough place to also filter out any '.'. There were a few similar filters which I updated, but have not tested.


(Tk actually does allow whitespace in pathnames; try


toplevel ".yes you\tcan\nuse\rwhitespace"

in wish. But something in Tcl::pTk or Tcl.pm does not handle this correctly, and possibly other code, so trying to allow whitespace is probably not be a good idea.)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.