@@ -206,6 +206,22 @@ def idle_draw(*args):
206206 self ._idle = True
207207 if d : QtCore .QTimer .singleShot (0 , idle_draw )
208208
209+
210+ # XXX Hackish fix: There's a bug in PyQt. See this thread for details:
211+ # http://old.nabble.com/Qt4-backend:-critical-bug-with-PyQt4-v4.6%2B-td26205716.html
212+ # Once a release of Qt/PyQt is available without the bug, the version check
213+ # below can be tightened further to only be applied in the necessary versions.
214+ if Qt .PYQT_VERSION_STR .startswith ('4.6' ):
215+ class FigureWindow (QtGui .QMainWindow ):
216+ def __init__ (self ):
217+ super (FigureWindow , self ).__init__ ()
218+ def closeEvent (self , event ):
219+ super (FigureWindow , self ).closeEvent (event )
220+ self .emit (Qt .SIGNAL ('destroyed()' ))
221+ else :
222+ FigureWindow = QtGui .QMainWindow
223+ # /end pyqt hackish bugfix
224+
209225class FigureManagerQT ( FigureManagerBase ):
210226 """
211227 Public attributes
@@ -220,7 +236,7 @@ def __init__( self, canvas, num ):
220236 if DEBUG : print 'FigureManagerQT.%s' % fn_name ()
221237 FigureManagerBase .__init__ ( self , canvas , num )
222238 self .canvas = canvas
223- self .window = QtGui . QMainWindow ()
239+ self .window = FigureWindow ()
224240 self .window .setAttribute (QtCore .Qt .WA_DeleteOnClose )
225241
226242 self .window .setWindowTitle ("Figure %d" % num )
0 commit comments