Tk Source Code

View Ticket
Login
Ticket UUID: 2160206
Title: Menubutton causing panic (Tk_MoveToplevelWindow)
Type: Bug Version: obsolete: 8.5.7
Submitter: eserte Created on: 2008-10-11 22:30:48
Subsystem: 12. Unix Menus Assigned To: fvogel
Priority: 8 Severity: Minor
Status: Closed Last Modified: 2015-11-08 20:55:41
Resolution: Fixed Closed By: fvogel
    Closed on: 2015-11-08 20:55:41
Description:
The following script causes a panic with Tk 8.4.x and Tk 8.5.4:

menubutton .mb -text test
pack .mb 
menu .mb.menu -type menubar
.mb configure -menu .mb.menu

The script is probably not meaningful, but IMHO shouldn't dump core.
(I discovered this bug trying out the "menubug" script in the Perl/Tk distribution)

Regards,
    Slaven
User Comments: fvogel added on 2015-11-08 20:55:41:
Merged to core-8-5-branch and trunk.

fvogel added on 2015-11-02 21:12:04:
No comment was received so far about my proposal in branch bug-2160206fff.

I'll let a few more days go to allow people to think at this, and then I will merge.

fvogel added on 2015-10-18 21:26:22:
The fact that menues of type menubar shall not be toplevels is needed on Linux (Windows does not care).

I tried to prevent the user from setting -type menubar, but as predicted by dkf I failed (due to the cloning mechanism running when configuring a toplevel with -menu .m, which changes the type of the menu to menubar -- no way to distinguish this from the user setting -type menubar by hand).

I have therefore resorted to preventing posting of menues of type -menubar. This was rather easy however. See branch bug-2160206.

The test suite is happy with this change, on both Linux and Windows.

What do other people think?

fvogel added on 2015-10-13 20:29:22:

Already reported in the past in [1567681].

Menues with '-type menubar' are explicitely set as non-toplevel in function MenuCmd.

I tend to agree wrt dkf's comment below on '2009-02-16 22:50:15'. However, do we really want to prevent the user from setting -type menubar at all? I'm not so sure.

Perhaps we could just throw an error when trying to post a menu of this type (MenuWidgetObjCmd, case MENU_POST).

Also, the fact it works for Windows is interesting.


hobbs added on 2009-05-09 02:43:37:
Confirmed in 8.4-head and 8.5-head on X11 but not Windows (Vista).  The panic returned is:
Tk_MoveToplevelWindow called with non-toplevel window

ferrieux added on 2009-02-16 23:01:58:
It's an old bug. Repro in Unix 8.4.7 and 8.3.5.

dkf added on 2009-02-16 22:50:15:
The bug is that we're not doing an error on the line before; nobody and nothing (except Tk's C guts) should set the type of a menu to "menubar". Don't know how to achieve this yet.

dkf added on 2009-02-16 22:26:28:
Reproduced with Unix build of Tk HEAD, and seems to be a Tcl_Panic(). Message was:
Tk_MoveToplevelWindow called with non-toplevel window

patthoyts added on 2008-11-04 06:18:41:
Failed to reproduce the crash on Windows using 8.4.19, 8.5.3 or 8.6a4. Possibly this is a unix specific menu problem.