]> granicus.if.org Git - python/commitdiff
Merged revisions 65622 via svnmerge from
authorRobert Schuppenies <okkotonushi@googlemail.com>
Sun, 10 Aug 2008 11:28:17 +0000 (11:28 +0000)
committerRobert Schuppenies <okkotonushi@googlemail.com>
Sun, 10 Aug 2008 11:28:17 +0000 (11:28 +0000)
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.
........

Lib/tkinter/__init__.py
Misc/NEWS

index 08c5823ce6a5da61a74359d4b34006fe97ca956a..b8508a568a02b77dac0e598fcc92835ab87407fb 100644 (file)
@@ -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)
index 25c72dffa5c563551d81c3bb5af4aaa616aa528d..dfa1a2f21776e093103d2df8a0cc393be9b35c1c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
+  menu entries were not deleted.
+
 - Remove the TarFileCompat class from tarfile.py.
 
 - Issue #2491: os.fdopen is now almost an alias for the built-in open(), and