@@ -152,6 +152,7 @@ def __init__( self, canvas, num ):
152152 FigureManagerBase .__init__ ( self , canvas , num )
153153 self .canvas = canvas
154154 self .window = qt .QMainWindow ( None , None , qt .Qt .WDestructiveClose )
155+ self .window .closeEvent = self ._widgetCloseEvent
155156
156157 centralWidget = qt .QWidget ( self .window )
157158 self .canvas .reparent ( centralWidget , qt .QPoint ( 0 , 0 ) )
@@ -161,8 +162,6 @@ def __init__( self, canvas, num ):
161162 self .canvas .setFocus ()
162163 self .window .setCaption ( "Figure %d" % num )
163164
164- qt .QObject .connect ( self .window , qt .SIGNAL ( 'destroyed()' ),
165- self ._widgetclosed )
166165 self .window ._destroying = False
167166
168167 if matplotlib .rcParams ['toolbar' ] == 'classic' :
@@ -209,6 +208,10 @@ def _widgetclosed( self ):
209208 self .window ._destroying = True
210209 Gcf .destroy (self .num )
211210
211+ def _widgetCloseEvent ( self , event ):
212+ self ._widgetclosed ()
213+ qt .QWidget .closeEvent ( self .window , event )
214+
212215 def destroy ( self , * args ):
213216 if self .window ._destroying : return
214217 self .window ._destroying = True
@@ -232,6 +235,7 @@ class NavigationToolbar2QT( NavigationToolbar2, qt.QWidget ):
232235 def __init__ ( self , parent , canvas ):
233236 self .canvas = canvas
234237 self .buttons = {}
238+
235239 qt .QWidget .__init__ ( self , parent )
236240
237241 # Layout toolbar buttons horizontally.
0 commit comments