[PyQt] Help with segfault in PyQt program

Phil Thompson phil at riverbankcomputing.com
Sun Sep 16 21:44:52 BST 2012

On Sun, 16 Sep 2012 22:40:29 +0530, Shriramana Sharma <samjnaa at gmail.com>
> Hello. I'm back on this list after quite some time.
> I'm working on some stuff involving bezier curves and wanted to write
> my own bezier display applet to keep in handy, so that I can adjust
> the nodes and handles and it would show me real-time what the
> resultant curve looks like.
> However even a minimal Bezier drawing (bezierview-0) throws errors on
> my main 64 bit system with PyQt 4.9.1 with Qt 4.8.1 on Kubuntu
> Precise. So I tested on a 32 bit Kubuntu Oneiric (older) VM
> installation I have which has PyQt 4.8.5 and Qt 4.7.4 and it worked OK
> enough. But once I got around to programming the important points
> (i.e. tweaking the points, see bezierview-1) it once more segfaulted
> even on that older system and I'm back to square one.
> Help please! (FWIW the code is GPLed.) The minimal stuff if written in
> C++ doesn't segfault on my latest Qt 4.8.1. (I was hoping to do
> everything in PyQt so I only wrote the minimal thing in C++ so far.)
> Thanks!

Your paintEvent() is broken because you are keeping references to the
painter (and most other things) when paintEvent() returns. Basically you
need to remove all the "self." from paintEvent() except those that
reference the genuine instance attributes. Attached is a fixed version of
your second example.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bezierview-1.py
Type: text/x-java
Size: 2972 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120916/fefeff9d/attachment.java>

More information about the PyQt mailing list