[PyKDE] canvas related segfault

Phil Thompson phil at riverbankcomputing.co.uk
Thu Feb 10 16:22:47 GMT 2005

> On Thursday 10 February 2005 11:08, Phil Thompson wrote:
>> > Hi Phil,
>> >
>> > there was a nice little qt tile based imaging example published
>> > today in the german linux magazine, and I thought, it would be
>> > nice to play with in PyQt, thus I converted it. Now it appears,
>> > that after loading an image and quitting, it segfaults
>> > reproducible, unless I use the WDestructiveClose flag on the main
>> > window. Here's a typical backtrace:
>> I haven't looked at this in detail, but the comments at the bottom
>> of canvas.py in the PyQt examples might be relevant here.
> Hmm, none of these lines below app.exec_loop() seems to be needed here
> as everthing is destructed just fine without them. So maybe this
> comment is misleading or outdated.

>From memory it's because QCanvas accesses any images in it's destructor.
If they have already been destroyed then there is a segfault. In canvas.py
the images and the QCanvas are referenced in the module dictionary and the
order in which they are garbage collected is non-deterministic. Those
extra lines ensure the QCanvas is destroyed before the images.

> BTW, doesn't that example miss
> some global statements at least?

Quite possibly - I didn't write it.

BTW, QObject.inherits() and QObject.isA() will be fixed in the next PyQt


More information about the PyQt mailing list