Permalink
Browse files

Merge pull request #1098 from efiring/suppress_closing_exception

suppress exception upon quitting with qt4agg on osx
  • Loading branch information...
2 parents 9aab0be + 9520d9f commit cf7618cacfea52535ea6c93b1add309e77b868a9 @efiring efiring committed Aug 29, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 lib/matplotlib/backend_bases.py
@@ -1599,11 +1599,13 @@ def close_event(self, guiEvent=None):
try:
event = CloseEvent(s, self, guiEvent=guiEvent)
self.callbacks.process(s, event)
- except TypeError:
+ except (TypeError, AttributeError):
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.
+ # AttributeError occurs on OSX with qt4agg upon exiting
+ # with an open window; 'callbacks' attribute no longer exists.
def key_press_event(self, key, guiEvent=None):
"""
@@ -2423,12 +2425,12 @@ def __init__(self, canvas, num):
self.key_press)
"""
The returned id from connecting the default key handler via :meth:`FigureCanvasBase.mpl_connnect`.
-
+
To disable default key press handling::
-
+
manager, canvas = figure.canvas.manager, figure.canvas
canvas.mpl_disconnect(manager.key_press_handler_id)
-
+
"""
def destroy(self):

0 comments on commit cf7618c

Please sign in to comment.