Skip to content

Commit 3d1c7de

Browse files
author
Robert Schuppenies
committed
Merged revisions 65622 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65622 | robert.schuppenies | 2008-08-10 13:01:53 +0200 (Sun, 10 Aug 2008) | 4 lines Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to menu entries were not deleted. ........
1 parent 2828ab2 commit 3d1c7de

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Lib/tkinter/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,18 @@ def insert_separator(self, index, cnf={}, **kw):
26512651
self.insert(index, 'separator', cnf or kw)
26522652
def delete(self, index1, index2=None):
26532653
"""Delete menu items between INDEX1 and INDEX2 (not included)."""
2654+
if index2 is None:
2655+
index2 = index1
2656+
cmds = []
2657+
for i in range(self.index(index1), self.index(index2)+1):
2658+
if 'command' in self.entryconfig(i):
2659+
c = str(self.entrycget(i, 'command'))
2660+
if c in self._tclCommands:
2661+
cmds.append(c)
26542662
self.tk.call(self._w, 'delete', index1, index2)
2663+
for c in cmds:
2664+
self.deletecommand(c)
2665+
26552666
def entrycget(self, index, option):
26562667
"""Return the resource value of an menu item for OPTION at INDEX."""
26572668
return self.tk.call(self._w, 'entrycget', index, '-' + option)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Core and Builtins
3030
Library
3131
-------
3232

33+
- Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
34+
menu entries were not deleted.
35+
3336
- Remove the TarFileCompat class from tarfile.py.
3437

3538
- Issue #2491: os.fdopen is now almost an alias for the built-in open(), and

0 commit comments

Comments
 (0)