diff options
author | dkf <dkf@noemail.net> | 2010-01-05 09:40:46 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2010-01-05 09:40:46 (GMT) |
commit | cf982106d6407fce2fca946dbd97664ca030c0c3 (patch) | |
tree | 94ed6c2ecb704bc3dd700c64e0531135a69e7aa4 | |
parent | e374ce6d6c73984767604d8947e8576297752bf1 (diff) | |
download | tk-cf982106d6407fce2fca946dbd97664ca030c0c3.zip tk-cf982106d6407fce2fca946dbd97664ca030c0c3.tar.gz tk-cf982106d6407fce2fca946dbd97664ca030c0c3.tar.bz2 |
[Bug 220950]: Don't delete the last menu entry when it is obvious that is not
what was intended.
FossilOrigin-Name: f49d1f0c9696c8f5f101da134c58b0e323db7565
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | generic/tkMenu.c | 15 | ||||
-rw-r--r-- | tests/menu.test | 13 |
3 files changed, 29 insertions, 3 deletions
@@ -1,5 +1,9 @@ 2010-01-05 Donal K. Fellows <dkf@users.sf.net> + * generic/tkMenu.c (MenuWidgetObjCmd): [Bug 220950]: Do not delete + menu entries if the first index to delete is explicitly after the last + index of existing entries. + * generic/tkFont.h (ROUND16): [Bug 2824916]: Use a correct rounding * unix/tkUnixFont.c (TkpDrawAngledChars): macro for converting a * unix/tkUnixRFont.c (TkpDrawAngledChars): double to a short. This diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 4c0cd41..4f97eb9 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.55 2010/01/02 22:52:38 dkf Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.56 2010/01/05 09:40:46 dkf Exp $ */ /* @@ -778,7 +778,18 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "first ?last?"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &first) != TCL_OK) { + + /* + * If 'first' explicitly refers to past the end of the menu, we don't + * do anything. [Bug 220950] + */ + + if (isdigit(UCHAR(Tcl_GetString(objv[2])[0])) + && Tcl_GetIntFromObj(NULL, objv[2], &first) == TCL_OK) { + if (first >= menuPtr->numEntries) { + goto done; + } + } else if (TkGetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){ goto error; } if (objc == 3) { diff --git a/tests/menu.test b/tests/menu.test index 25caf35..5dd89ab 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -5,7 +5,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: menu.test,v 1.25 2010/01/03 00:18:19 patthoyts Exp $ +# RCS: @(#) $Id: menu.test,v 1.26 2010/01/05 09:40:46 dkf Exp $ package require tcltest 2.2 namespace import ::tcltest::* @@ -1455,6 +1455,17 @@ test menu-3.29 {MenuWidgetCmd procedure, "delete" option} -setup { } -cleanup { destroy .m1 } -result {} +test menu-3.29+1 {MenuWidgetCmd, "delete", Bug 220950} -setup { + destroy .m1 +} -body { + menu .m1 + .m1 add command -label "bogus" + .m1 add command -label "ok" + .m1 delete 10 20 + .m1 entrycget last -label +} -cleanup { + destroy .m1 +} -result ok test menu-3.30 {MenuWidgetCmd procedure, "entrycget" option} -setup { destroy .m1 } -body { |