summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2015-11-08 20:54:16 (GMT)
committerfvogel <fvogelnew1@free.fr>2015-11-08 20:54:16 (GMT)
commit73b89417809cc91f33a1a6c9679510b21129db52 (patch)
tree3c47999b22defcaefabb3c32718df5fea64b94b7
parentdc5e0089024a6f532879a8c22014223925b8f37d (diff)
parent2028daf50bcb641a8be43c4989a37074d5a00f72 (diff)
downloadtk-73b89417809cc91f33a1a6c9679510b21129db52.zip
tk-73b89417809cc91f33a1a6c9679510b21129db52.tar.gz
tk-73b89417809cc91f33a1a6c9679510b21129db52.tar.bz2
Fixed [2160206fff] - Panic when posting a menu of type menubar
-rw-r--r--generic/tkMenu.c7
-rw-r--r--tests/menu.test12
2 files changed, 18 insertions, 1 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 354d329..d24516f 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -885,9 +885,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);
diff --git a/tests/menu.test b/tests/menu.test
index 59239d7..aaadc86 100644
--- a/tests/menu.test
+++ b/tests/menu.test
@@ -3867,6 +3867,18 @@ test menu-35.1 {menu -underline string overruns Bug 1599877} -setup {
deleteWindows
} -result {}
+test menu-37.1 {menubar menues cannot be posted - bug 2160206} -setup {
+ catch {destroy .m}
+} -body {
+ # On Linux the following used to panic
+ # It now returns an error (on all platforms)
+ menu .m -type menubar
+ list [catch ".m post 1 1" msg] $msg
+} -cleanup {
+ destroy .m
+} -result {1 {a menubar menu cannot be posted}}
+
+
# cleanup
imageFinish
deleteWindows