[Python-checkins] r65624 - in python/branches/release25-maint: Lib/lib-tk/Tkinter.py Misc/NEWS

robert.schuppenies python-checkins at python.org
Sun Aug 10 13:19:26 CEST 2008


Author: robert.schuppenies
Date: Sun Aug 10 13:19:25 2008
New Revision: 65624

Log:
Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
menu entries were not deleted.

Backport from trunk r65622.


Modified:
   python/branches/release25-maint/Lib/lib-tk/Tkinter.py
   python/branches/release25-maint/Misc/NEWS

Modified: python/branches/release25-maint/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/branches/release25-maint/Lib/lib-tk/Tkinter.py	(original)
+++ python/branches/release25-maint/Lib/lib-tk/Tkinter.py	Sun Aug 10 13:19:25 2008
@@ -2669,7 +2669,17 @@
         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)

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Sun Aug 10 13:19:25 2008
@@ -74,6 +74,9 @@
 Library
 -------
 
+- Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
+  menu entries were not deleted.
+
 - Issue #799428: Fix Tkinter.Misc._nametowidget to unwrap Tcl command objects.
 
 - Issue #3339: dummy_thread.acquire() could return None which is not a valid


More information about the Python-checkins mailing list