PyQT-application crash when shutting down

Andrew Dalke adalke at mindspring.com
Sun Jan 26 16:05:26 EST 2003


Albert Hofkamp wrote:
> I am writing an animation application using PyQt at a Redhat 7.2 machine
> (RPM: PyQt-devel-3.1-2).
> The application seems to be working fine, but when I press the 'Quit'
> button (which sends a 'clicked' signal to the 'quit' slot of the main
> application), I get a "segmentation fault".
> Below is a stripped-down application that demonstrates the problem (at
> least at my machine):

> if __name__ == '__main__':
>     app=QApplication(sys.argv)
>     aw=ApplicationWindow()
>     app.setMainWidget(aw)
>     app.connect(aw._quit,SIGNAL("clicked()"),app,SLOT("quit()"))
>     aw.show()
>     app.exec_loop()
> 
> I don't understand why this happens. If the application is closed with the
> 'close window' button, it exits without problems.
> 
> Any ideas?

I get similar behaviour.  I think it's because the deallocator for
app and aw are in indefinite order, but Qt requires aw to be deallocated
first.  I end up writing my scripts like this

def main(app):
     aw=ApplicationWindow()
     app.setMainWidget(aw)
     app.connect(aw._quit,SIGNAL("clicked()"),app,SLOT("quit()"))
     aw.show()
     app.exec_loop()

if __name__ == "__main__":
     app = QApplication(sys.argv)
     main(app)

                                          Andrew
                                          dalke at dalkescientific.com





More information about the Python-list mailing list