[PyKDE] QCanvasSprite segfaulting

Phil Thompson phil at river-bank.demon.co.uk
Tue Feb 18 12:49:00 GMT 2003


On Tuesday 18 February 2003 8:13 am, Vio wrote:
> Greetings,
> Newbie hits wall while dipping toe in QCanvas.
> Would someone be kind enough to tell
> me why I get a segfault while trying to "show()" a sprite?
>
>
> my entire code:
>
> # START OF CODE --------------------------------------------
> #
> # Testing QCanvas
> #
>
> import sys
> from qt import *
> from qtcanvas import *
> TRUE = 1
> FALSE = 0
>
> class MY(QCanvas):
>
>       def __init__(self,h = 1000, w=1000):
> 		QCanvas.__init__(self,h,w)
> 		self.view =  QCanvasView(self)
>
> # testing text
> 		self.item = QCanvasText('Testosterone',QFont (),self)
> 		self.item.setX(50)
> 		self.item.setY(50)
> 		self.item.show()
>
> # testing sprite
> 		spix = QCanvasPixmapArray()
> 		spix.setImage(0,QCanvasPixmap("test.png"))
> 		sprite = QCanvasSprite(spix, self)
> 		sprite.move(100, 100, 0)
> 		sprite.show() #<-- gives Segmentation fault
> # error message:
> #QPixmap::operator=: Cannot assign to pixmap during painting
>
> # Note: if commenting out the "sprite.show()" line, the QCanvasText
> # shows up as expected.
>
>
> # show items on screen
> 		self.view.show()
> 		self.update()
>
>
> if __name__ == "__main__":
> 	a = QApplication(sys.argv)
> 	QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
> 	w = MY()
> 	a.exec_loop()
>
> # END OF CODE --------------------------------------------

I haven't got time to investigate this properly at the moment, but the 
canvas.py example script seems to have a similar problem (if you start a 
sprite). Both segfault in the QCanvasSprite::topEdge() method in Qt itself, 
although the backtrace.

The C++ version of canvas.py doesn't have the problem, so the most likely 
cause is a PyQt bug.

Phil




More information about the PyQt mailing list