From 72df3089578116c1b9fdfb15a1c9b1e20a66dc2a Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 18 Oct 2015 21:24:57 +0000 Subject: Proposed fix for [2160206fff] - Panic (Linux) when posting a menu of type menubar --- generic/tkMenu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 49b5935..b35be24 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -934,9 +934,14 @@ MenuWidgetObjCmd( * Tearoff menus are posted differently on Mac and Windows than * non-tearoffs. TkpPostMenu does not actually map the menu's window * on those platforms, and popup menus have to be handled specially. + * Also, menubar menues are not intended to be posted (bug 1567681, + * 2160206). */ - if (menuPtr->menuType != TEAROFF_MENU) { + if (menuPtr->menuType == MENUBAR) { + Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); + return TCL_ERROR; + } else if (menuPtr->menuType != TEAROFF_MENU) { result = TkpPostMenu(interp, menuPtr, x, y); } else { result = TkPostTearoffMenu(interp, menuPtr, x, y); -- cgit v0.12 From 2fb7c126ab1a68f237aee91ecd26b5f2eb6e074d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 25 Oct 2015 19:58:08 +0000 Subject: Added new test to check for error triggering when posting a menu of type menubar --- tests/menu.test | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/menu.test b/tests/menu.test index cfe00b9..c797281 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -2566,6 +2566,15 @@ test menu-36.1 {menu -underline string overruns Bug 1599877} {} { tk::TraverseToMenu . "e" } {} +test menu-37.1 {menubar menues cannot be posted - bug 2160206} {} { + # On Linux the following used to panic + # It now returns an error (on all platforms) + catch {destroy .m} + menu .m -type menubar + list [catch ".m post 1 1" msg] $msg +} {1 {a menubar menu cannot be posted}} + + # cleanup deleteWindows cleanupTests -- cgit v0.12