diff options
author | Robert Schuppenies <okkotonushi@googlemail.com> | 2008-08-10 11:28:17 (GMT) |
---|---|---|
committer | Robert Schuppenies <okkotonushi@googlemail.com> | 2008-08-10 11:28:17 (GMT) |
commit | 3d1c7dec4af44134390addc25b002dfd22c4c3f8 (patch) | |
tree | 23d93e5bfcaee52be002f2e4cd1443915d7b1d87 /Lib/tkinter | |
parent | 2828ab2c55b5719416b413608b54c0169b49ff82 (diff) | |
download | cpython-3d1c7dec4af44134390addc25b002dfd22c4c3f8.zip cpython-3d1c7dec4af44134390addc25b002dfd22c4c3f8.tar.gz cpython-3d1c7dec4af44134390addc25b002dfd22c4c3f8.tar.bz2 |
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.
........
Diffstat (limited to 'Lib/tkinter')
-rw-r--r-- | Lib/tkinter/__init__.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 08c5823..b8508a5 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -2651,7 +2651,18 @@ class Menu(Widget): self.insert(index, 'separator', cnf or kw) def delete(self, index1, index2=None): """Delete menu items between INDEX1 and INDEX2 (not included).""" + if index2 is None: + index2 = index1 + cmds = [] + for i in range(self.index(index1), self.index(index2)+1): + if 'command' in self.entryconfig(i): + c = str(self.entrycget(i, 'command')) + if c in self._tclCommands: + cmds.append(c) self.tk.call(self._w, 'delete', index1, index2) + for c in cmds: + self.deletecommand(c) + def entrycget(self, index, option): """Return the resource value of an menu item for OPTION at INDEX.""" return self.tk.call(self._w, 'entrycget', index, '-' + option) |