[PyQt] Freezes and crashes with signal autoconnection

Phil Thompson phil at riverbankcomputing.com
Wed Dec 9 13:20:18 GMT 2009

On Tue, 8 Dec 2009 14:10:50 -0800 (PST), Christian Roche
<christian.roche.fr at gmail.com> wrote:
> Hi Phil,
> thanks for the detailed explanation, although I have to admit I have a
> of a hard time following through.. Anyway...
> Phil Thompson-5 wrote:
>> I've already suggested that you should simplify your ImageLink class so
>> that it does not derive from QObject.
> Okay but there must be something else here, I did just what you suggested

> http://old.nabble.com/file/p26701730/main.py here  (I had to replace
> ImageLink arguments in signal definition with 'PyQt_PyObject', not sure
> exactly)

Neither am I.

> Still I get the same crash, after a few get_param iterations though,
> makes me believe it's not a pure GC'ed object issue :

If you'd simplified the example further - got rid of the thread, got rid of
the GUI, got rid of the connection you'd see that the problem is related to
the URL processing.

The bug is this line in get_param()...

    res = ulist.first()

...which returns the first string in the list and *not* a copy of the first
string in the list. The result is that you are still using it after Qt has
destroyed it. This behaviour is horribly un-Pythonic but allowed (so I
can't change it as doing so might break other people's code).

Change the line to...

    res = ulist[0]

...and it should be Ok.


More information about the PyQt mailing list