Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method #3025

Merged
merged 1 commit into from Aug 8, 2017
Merged

bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method #3025

merged 1 commit into from Aug 8, 2017

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Aug 8, 2017

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

https://bugs.python.org/issue31135

@vstinner vstinner changed the title ttk: fix LabeledScale and OptionMenu destroy() method bpo-31135: ttk: fix LabeledScale and OptionMenu destroy() method Aug 8, 2017
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.
@vstinner vstinner merged commit cd7e9c1 into python:master Aug 8, 2017
@vstinner vstinner deleted the ttk branch August 8, 2017 17:41
pass
else:
del self._variable
Frame.destroy(self)
super().destroy()
self.label = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not del them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike when attributes "disappear". I prefer setting them to None. Moreover, "self.label = None" doesn't fail if destroy() is called twice, whereas "del self._variable" requires a try/except AttributeError.

pass
else:
del self._variable
Frame.destroy(self)
super().destroy()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parent's destroy() now is called even if this destroy() already was called. I.e. it can be called twice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a deliberate choice. All other ttk widgets now have the same behaviour.

vstinner added a commit that referenced this pull request Aug 9, 2017
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 cd7e9c1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants