From: <ef...@us...> - 2010-06-04 19:20:53
|
Revision: 8378 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8378&view=rev Author: efiring Date: 2010-06-04 19:20:47 +0000 (Fri, 04 Jun 2010) Log Message: ----------- suppress spurious exceptions when killing a qt4 session. While investigating 2927619 I found that killing a python session with an active qt4 window generated Exceptions because callbacks were being executed after their modules had been deleted. There may be a cleaner solution than the one I implemented, which is merely to catch the useless exceptions. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-06-04 18:47:48 UTC (rev 8377) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-06-04 19:20:47 UTC (rev 8378) @@ -1447,8 +1447,14 @@ 'close_event' with a :class:`CloseEvent` """ s = 'close_event' - event = CloseEvent(s, self, guiEvent=guiEvent) - self.callbacks.process(s, event) + try: + event = CloseEvent(s, self, guiEvent=guiEvent) + self.callbacks.process(s, event) + except TypeError: + pass + # Suppress the TypeError when the python session is being killed. + # It may be that a better solution would be a mechanism to + # disconnect all callbacks upon shutdown. def key_press_event(self, key, guiEvent=None): """ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-06-04 18:47:48 UTC (rev 8377) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2010-06-04 19:20:47 UTC (rev 8378) @@ -87,7 +87,7 @@ class TimerQT(TimerBase): ''' Subclass of :class:`backend_bases.TimerBase` that uses Qt4 timer events. - + Attributes: * interval: The time between timer events in milliseconds. Default is 1000 ms. @@ -99,7 +99,7 @@ ''' def __init__(self, *args, **kwargs): TimerBase.__init__(self, *args, **kwargs) - + # Create a new timer and connect the timeout() signal to the # _on_timer method. self._timer = QtCore.QTimer() @@ -237,9 +237,9 @@ Creates a new backend-specific subclass of :class:`backend_bases.Timer`. This is useful for getting periodic events through the backend's native event loop. Implemented only for backends with GUIs. - + optional arguments: - + *interval* Timer interval in milliseconds *callbacks* @@ -341,8 +341,15 @@ def _widgetclosed( self ): if self.window._destroying: return self.window._destroying = True - Gcf.destroy(self.num) + try: + Gcf.destroy(self.num) + except AttributeError: + pass + # It seems that when the python session is killed, + # Gcf can get destroyed before the Gcf.destroy + # line is run, leading to a useless AttributeError. + def _get_toolbar(self, canvas, parent): # must be inited after the window, drawingArea and figure # attrs are set This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |