[PyQt] Bye bye segmentation fault

Phil Thompson phil at riverbankcomputing.com
Mon Sep 20 10:02:07 BST 2010


On Mon, 20 Sep 2010 10:07:30 +0200, Cyril Giraudon
<cyril.giraudon at free.fr>
wrote:
> Hello,
> 
> I am a PyQt newbye and I wanted to do some tests with QToolBar in a 
> QDialog (Seems multiple QMainWindow use is not recommanded in a 
> QApplication), so I started coding a simple example (reported below).
> 
> The code seems correct but it terminates with a segmentation fault when 
> the QUIT button is pressed :

Are you sure? Or does it fault when the interpreter is being destroyed? To
find out put a "print" after the call to exec_().

BTW, it works fine for me.

> """""""""""""""""""""""""""""""""""""
> (sandbox)cyril at CGN-L: pyqt$ python example.py
> Qt version :  4.6.2
> PyQt version :  4.7.2
> Erreur de segmentation
> """""""""""""""""""""""""""""""""""""
> 
> I don't understand what happens.
> Is there any explanation ?

Plenty in the mailing list archives, though I will add a section to the
docs.

The most likely problem is that things are getting garbage collected in
the wrong order (as far as Qt is concerned) when the interpreter gets
destroyed.

In a real application you tend to naturally structure things so that this
doesn't happen.

Phil



More information about the PyQt mailing list