@@ -208,18 +208,6 @@ def __init__( self, figure ):
208208 w ,h = self .get_width_height ()
209209 self .resize ( w , h )
210210
211- # JDH: Note the commented out code below does not work as
212- # expected, because according to Pierre Raybaut, The reason is
213- # that PyQt fails (silently) to call a method of this object
214- # just before detroying it. Using a lambda function will work,
215- # exactly the same as using a function (which is not bound to
216- # the object to be destroyed).
217- #
218- #QtCore.QObject.connect(self, QtCore.SIGNAL('destroyed()'),
219- # self.close_event)
220- QtCore .QObject .connect (self , QtCore .SIGNAL ('destroyed()' ),
221- lambda : self .close_event ())
222-
223211 def __timerEvent (self , event ):
224212 # hide until we can test and fix
225213 self .mpl_idle_event (event )
@@ -379,6 +367,10 @@ def idle_draw(*args):
379367 self ._idle = True
380368 if d : QtCore .QTimer .singleShot (0 , idle_draw )
381369
370+ class MainWindow (QtGui .QMainWindow ):
371+ def closeEvent (self , event ):
372+ self .emit (QtCore .SIGNAL ('closing()' ))
373+
382374class FigureManagerQT ( FigureManagerBase ):
383375 """
384376 Public attributes
@@ -393,8 +385,9 @@ def __init__( self, canvas, num ):
393385 if DEBUG : print ('FigureManagerQT.%s' % fn_name ())
394386 FigureManagerBase .__init__ ( self , canvas , num )
395387 self .canvas = canvas
396- self .window = QtGui .QMainWindow ()
397- self .window .setAttribute (QtCore .Qt .WA_DeleteOnClose )
388+ self .window = MainWindow ()
389+ self .window .connect (self .window , QtCore .SIGNAL ('closing()' ),
390+ canvas .close_event )
398391
399392 self .window .setWindowTitle ("Figure %d" % num )
400393 image = os .path .join ( matplotlib .rcParams ['datapath' ],'images' ,'matplotlib.png' )
@@ -621,7 +614,6 @@ def draw_rubberband( self, event, x0, y0, x1, y1 ):
621614 def configure_subplots (self ):
622615 self .adj_window = QtGui .QMainWindow ()
623616 win = self .adj_window
624- win .setAttribute (QtCore .Qt .WA_DeleteOnClose )
625617
626618 win .setWindowTitle ("Subplot Configuration Tool" )
627619 image = os .path .join ( matplotlib .rcParams ['datapath' ],'images' ,'matplotlib.png' )
0 commit comments