@@ -75,7 +75,7 @@ def paintEvent( self, e ):
7575 p = qt .QPainter ( self )
7676
7777 # only replot data when needed
78- if type (self .replot ) is bool :
78+ if type (self .replot ) is bool : # might be a bbox for blitting
7979 if self .replot :
8080 FigureCanvasAgg .draw ( self )
8181 stringBuffer = str ( self .buffer_rgba (0 ,0 ) )
@@ -103,13 +103,16 @@ def paintEvent( self, e ):
103103 p .drawRect ( self .rect [0 ], self .rect [1 ], self .rect [2 ], self .rect [3 ] )
104104
105105 # we are blitting here
106- else :
106+ else : # TODO: Fix memory leak
107107 bbox = self .replot
108- self .restore_region (self .copy_from_bbox (bbox ))
109- p .drawPixmap (qt .QPoint (bbox .ll ().x ().get (),
110- bbox .ll ().y ().get ()),
111- self .pixmap )
112-
108+ w , h = int (bbox .width ()), int (bbox .height ())
109+ l , t = bbox .ll ().x ().get (), bbox .ur ().y ().get ()
110+ reg = self .copy_from_bbox (bbox )
111+ stringBuffer = reg .to_string ()
112+ qImage = qt .QImage (stringBuffer , w , h , 32 , None , 0 , qt .QImage .IgnoreEndian )
113+ self .pixmap .convertFromImage (qImage , qt .QPixmap .Color )
114+ p .drawPixmap (qt .QPoint (l , self .renderer .height - t ), self .pixmap )
115+
113116 p .end ()
114117 self .replot = False
115118 self .drawRect = False
0 commit comments