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

Skip to content

Commit 2ab41d2

Browse files
committed
Avoid annoying Qt4 messages when mpl raises an exception. (Thanks to
Martin Teichmann in patch 1828813) svn path=/trunk/matplotlib/; revision=4178
1 parent e2b07a3 commit 2ab41d2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ def paintEvent( self, e ):
8080
if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
8181
self.get_width_height()
8282

83-
p = QtGui.QPainter( self )
84-
8583
# only replot data when needed
8684
if type(self.replot) is bool: # might be a bbox for blitting
8785
if self.replot:
@@ -99,13 +97,15 @@ def paintEvent( self, e ):
9997
qImage = QtGui.QImage(stringBuffer, self.renderer.width,
10098
self.renderer.height,
10199
QtGui.QImage.Format_ARGB32)
100+
p = QtGui.QPainter(self)
102101
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))
103102

104103
# draw the zoom rectangle to the QPainter
105104
if self.drawRect:
106105
p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) )
107106
p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )
108107

108+
p.end()
109109
# we are blitting here
110110
else:
111111
bbox = self.replot
@@ -114,10 +114,10 @@ def paintEvent( self, e ):
114114
reg = self.copy_from_bbox(bbox)
115115
stringBuffer = reg.to_string()
116116
qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
117+
p = QtGui.QPainter(self)
117118
pixmap = QtGui.QPixmap.fromImage(qImage)
118119
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
119-
120-
p.end()
120+
p.end()
121121
self.replot = False
122122
self.drawRect = False
123123

0 commit comments

Comments
 (0)