Kaydet (Commit) 14646337 authored tarafından Robert Schuppenies's avatar Robert Schuppenies

Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to

menu entries were not deleted.
üst 9fc5631b
...@@ -2659,7 +2659,17 @@ class Menu(Widget): ...@@ -2659,7 +2659,17 @@ class Menu(Widget):
self.insert(index, 'separator', cnf or kw) self.insert(index, 'separator', cnf or kw)
def delete(self, index1, index2=None): def delete(self, index1, index2=None):
"""Delete menu items between INDEX1 and INDEX2 (not included).""" """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) self.tk.call(self._w, 'delete', index1, index2)
for c in cmds:
self.deletecommand(c)
def entrycget(self, index, option): def entrycget(self, index, option):
"""Return the resource value of an menu item for OPTION at INDEX.""" """Return the resource value of an menu item for OPTION at INDEX."""
return self.tk.call(self._w, 'entrycget', index, '-' + option) return self.tk.call(self._w, 'entrycget', index, '-' + option)
......
...@@ -41,6 +41,9 @@ Core and Builtins ...@@ -41,6 +41,9 @@ Core and Builtins
Library Library
------- -------
- Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
menu entries were not deleted.
- Copied the implementation of reduce() to _functools.reduce() to have a - Copied the implementation of reduce() to _functools.reduce() to have a
version that did not raise a DeprecationWarning under -3. version that did not raise a DeprecationWarning under -3.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment