Avoid the following error, in case the Window __del__ method tries to close an already closed window:
TypeError: 'NoneType' object is not iterable
@@ -580,9 +580,13 @@ class BaseWindow(with_metaclass(_WindowMetaclass, EventDispatcher)):
self.activate()
def __del__(self):
- # Always clean up the window when it is dereferenced.
+ # Always try to clean up the window when it is dereferenced.
# Makes sure there are no dangling pointers or memory leaks.
+ # If the window is already closed, pass silently.
+ try:
self.close()
+ except TypeError: # XXX Avoid a NoneType error if already closed.
+ pass
def __repr__(self):
return '%s(width=%d, height=%d)' % \
