Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed7a15f

Browse files
committed
workaround for a regression in PyQt4-4.6.{0,1}
svn path=/trunk/matplotlib/; revision=8056
1 parent 605aebb commit ed7a15f

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2009-12-31 Commit a workaround for a regression in PyQt4-4.6.{0,1} - DSD
2+
13
2009-12-22 Fix cmap data for gist_earth_r, etc. -JJL
24

35
2009-12-20 spines: put spines in data coordinates, add set_bounds()

lib/matplotlib/backends/backend_qt4.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
209225
class 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

Comments
 (0)