Kaydet (Commit) 33460fa7 authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

ttk: fix LabeledScale and OptionMenu destroy() method (#3025) (#3030)

bpo-31135: Call the parent destroy() method even if the used
attribute doesn't exist.

The LabeledScale.destroy() method now also explicitly clears label
and scale attributes to help the garbage collector to destroy all
widgets.
(cherry picked from commit cd7e9c1b)
üst e93135db
...@@ -1543,11 +1543,12 @@ class LabeledScale(Frame): ...@@ -1543,11 +1543,12 @@ class LabeledScale(Frame):
try: try:
self._variable.trace_vdelete('w', self.__tracecb) self._variable.trace_vdelete('w', self.__tracecb)
except AttributeError: except AttributeError:
# widget has been destroyed already
pass pass
else: else:
del self._variable del self._variable
Frame.destroy(self) super().destroy()
self.label = None
self.scale = None
def _adjust(self, *args): def _adjust(self, *args):
...@@ -1647,5 +1648,8 @@ class OptionMenu(Menubutton): ...@@ -1647,5 +1648,8 @@ class OptionMenu(Menubutton):
def destroy(self): def destroy(self):
"""Destroy this widget and its associated variable.""" """Destroy this widget and its associated variable."""
del self._variable try:
Menubutton.destroy(self) del self._variable
except AttributeError:
pass
super().destroy()
ttk: fix the destroy() method of LabeledScale and OptionMenu classes.
Call the parent destroy() method even if the used attribute doesn't
exist. The LabeledScale.destroy() method now also explicitly clears label and
scale attributes to help the garbage collector to destroy all widgets.
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