diff options
author | hobbs <hobbs> | 2001-04-03 06:54:33 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-04-03 06:54:33 (GMT) |
commit | b65384d6930cbbd32cddfdaf9fde1ca54b898f27 (patch) | |
tree | 1709190e59d7259547594bb9b7cf86f677a716f0 /generic | |
parent | da15aaf9811e49f7f042dfea548c2bce739467d8 (diff) | |
download | tk-b65384d6930cbbd32cddfdaf9fde1ca54b898f27.zip tk-b65384d6930cbbd32cddfdaf9fde1ca54b898f27.tar.gz tk-b65384d6930cbbd32cddfdaf9fde1ca54b898f27.tar.bz2 |
* generic/tkMenu.c (TkInvokeMenu): checked for menu deletion
before calling associated menu entry command. [Bug #220821]
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkMenu.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c index b539186..3661fa7 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.9 2000/11/22 01:49:38 ericm Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.10 2001/04/03 06:54:33 hobbs Exp $ */ /* @@ -1106,7 +1106,13 @@ TkInvokeMenu(interp, menuPtr, index) } Tcl_DecrRefCount(valuePtr); } - if ((result == TCL_OK) && (mePtr->commandPtr != NULL)) { + /* + * We check numEntries in addition to whether the menu entry + * has a command because that goes to zero if the menu gets + * deleted (e.g., during command evaluation). + */ + if ((menuPtr->numEntries != 0) && (result == TCL_OK) + && (mePtr->commandPtr != NULL)) { Tcl_Obj *commandPtr = mePtr->commandPtr; Tcl_IncrRefCount(commandPtr); @@ -1115,7 +1121,7 @@ TkInvokeMenu(interp, menuPtr, index) } Tcl_Release((ClientData) mePtr); done: - return result; + return result; } /* @@ -1263,14 +1269,14 @@ TkDestroyMenu(menuPtr) if (menuPtr->menuFlags & MENU_DELETION_PENDING) { return; } - + /* * Now destroy all non-tearoff instances of this menu if this is a * parent menu. Is this loop safe enough? Are there going to be * destroy bindings on child menus which kill the parent? If not, * we have to do a slightly more complex scheme. */ - + if (menuPtr->masterMenuPtr == menuPtr) { menuPtr->menuFlags |= MENU_DELETION_PENDING; while (menuPtr->nextInstancePtr != NULL) { @@ -1287,13 +1293,13 @@ TkDestroyMenu(menuPtr) * If any toplevel widgets have this menu as their menubar, * the geometry of the window may have to be recalculated. */ - + topLevelListPtr = menuPtr->menuRefPtr->topLevelListPtr; while (topLevelListPtr != NULL) { nextTopLevelPtr = topLevelListPtr->nextPtr; TkpSetWindowMenuBar(topLevelListPtr->tkwin, NULL); topLevelListPtr = nextTopLevelPtr; - } + } DestroyMenuInstance(menuPtr); } |